Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
FixtureModel Class Reference

Public Member Functions

 __construct (IndexerReindexCommand $reindexCommand, $initArguments=[])
 
 reindex (OutputInterface $output)
 
 getParamLabels ()
 
 getFixtures ()
 
 getFixtureByName ($name)
 
 getObjectManager ()
 
 initObjectManager ($area=self::AREA_CODE)
 
 resetObjectManager ()
 
 loadConfig ($filename)
 
 getValue ($key, $default=null)
 

Data Fields

const AREA_CODE = 'adminhtml'
 
const FIXTURE_PATTERN = '?*Fixture.php'
 

Protected Attributes

 $application
 
 $objectManager
 
 $fixtures = []
 
 $paramLabels = []
 
 $initArguments
 

Detailed Description

@SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 20 of file FixtureModel.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( IndexerReindexCommand  $reindexCommand,
  $initArguments = [] 
)

Constructor

Parameters
IndexerReindexCommand$reindexCommand
array$initArguments

Definition at line 82 of file FixtureModel.php.

83  {
84  $this->initArguments = $initArguments;
85  $this->reindexCommand = $reindexCommand;
86  }

Member Function Documentation

◆ getFixtureByName()

getFixtureByName (   $name)

Returns fixture by name

Parameters
$namestring
Returns
\Magento\Setup\Fixtures\Fixture
Exceptions

Definition at line 165 of file FixtureModel.php.

166  {
167  if (!array_key_exists($name, $this->fixturesByNames)) {
168  throw new Exception('Wrong fixture name');
169  }
170 
171  return $this->fixturesByNames[$name];
172  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getFixtures()

getFixtures ( )

Get fixtures

Returns
Fixture[]

Definition at line 154 of file FixtureModel.php.

155  {
156  return $this->fixtures;
157  }

◆ getObjectManager()

getObjectManager ( )

Get object manager

Returns
\Magento\Framework\ObjectManagerInterface

Definition at line 179 of file FixtureModel.php.

180  {
181  if (!$this->objectManager) {
183  BP,
184  $this->initArguments
185  );
186  $this->objectManager = $objectManagerFactory->create($this->initArguments);
187  $this->objectManager->get(\Magento\Framework\App\State::class)->setAreaCode(self::AREA_CODE);
188  }
189 
190  return $this->objectManager;
191  }
$objectManagerFactory
static createObjectManagerFactory($rootDir, array $initParams)
Definition: Bootstrap.php:149
const BP
Definition: autoload.php:14

◆ getParamLabels()

getParamLabels ( )

Get param labels

Returns
array
Deprecated:
2.2.0

Definition at line 144 of file FixtureModel.php.

◆ getValue()

getValue (   $key,
  $default = null 
)

Get profile configuration value

Parameters
string$key
null | mixed$default
Returns
mixed

Definition at line 268 of file FixtureModel.php.

269  {
270  return $this->getConfig()->getValue($key, $default);
271  }

◆ initObjectManager()

initObjectManager (   $area = self::AREA_CODE)

Init Object Manager

Parameters
string$area
Returns
FixtureModel

Definition at line 199 of file FixtureModel.php.

200  {
201  $objectManger = $this->getObjectManager();
202  $configuration = $objectManger
203  ->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class)
204  ->load($area);
205  $objectManger->configure($configuration);
206 
207  $diConfiguration = $this->getValue('di');
208  if (file_exists($diConfiguration)) {
209  $dom = new \DOMDocument();
210  $dom->load($diConfiguration);
211 
212  $objectManger->configure(
213  $objectManger
214  ->get(\Magento\Framework\ObjectManager\Config\Mapper\Dom::class)
215  ->convert($dom)
216  );
217  }
218 
219  $objectManger->get(\Magento\Framework\Config\ScopeInterface::class)
220  ->setCurrentScope($area);
221  return $this;
222  }
$configuration
Definition: index.php:33

◆ loadConfig()

loadConfig (   $filename)

Load config from file

Parameters
string$filename
Exceptions

Definition at line 255 of file FixtureModel.php.

256  {
257  return $this->getConfig()->loadConfig($filename);
258  }

◆ reindex()

reindex ( OutputInterface  $output)

Run reindex

Parameters
OutputInterface$output
Returns
void

Definition at line 94 of file FixtureModel.php.

95  {
96  $input = new ArrayInput([]);
97  $this->reindexCommand->run($input, $output);
98  }

◆ resetObjectManager()

resetObjectManager ( )

Reset object manager

Returns
\Magento\Framework\ObjectManagerInterface
Deprecated:
2.2.0

Definition at line 230 of file FixtureModel.php.

231  {
232  return $this;
233  }

Field Documentation

◆ $application

$application
protected

Definition at line 37 of file FixtureModel.php.

◆ $fixtures

$fixtures = []
protected

Definition at line 49 of file FixtureModel.php.

◆ $initArguments

$initArguments
protected

Definition at line 69 of file FixtureModel.php.

◆ $objectManager

$objectManager
protected

Definition at line 42 of file FixtureModel.php.

◆ $paramLabels

$paramLabels = []
protected

Definition at line 64 of file FixtureModel.php.

◆ AREA_CODE

const AREA_CODE = 'adminhtml'

Area code

Definition at line 25 of file FixtureModel.php.

◆ FIXTURE_PATTERN

const FIXTURE_PATTERN = '?*Fixture.php'

Fixtures file name pattern

Definition at line 30 of file FixtureModel.php.


The documentation for this class was generated from the following file: