Ejemplo n.º 1
0
    /**
     * {@inheritdoc}
     */
    public function doOperation()
    {
        if (empty($this->data)) {
            return;
        }
        $this->interceptionConfigurationBuilder->addAreaCode(App\Area::AREA_GLOBAL);

        foreach ($this->areaList->getCodes() as $areaCode) {
            $this->interceptionConfigurationBuilder->addAreaCode($areaCode);
        }

        $classesList = [];
        foreach ($this->data['intercepted_paths'] as $path) {
            $classesList = array_merge($classesList, $this->classesScanner->getList($path));
        }

        $generatorIo = new \Magento\Framework\Code\Generator\Io(
            new \Magento\Framework\Filesystem\Driver\File(),
            $this->data['path_to_store']
        );
        $generator = $this->generatorFactory->create(
            [
                'ioObject' => $generatorIo,
                'generatedEntities' => [
                    Interceptor::ENTITY_TYPE => 'Magento\Setup\Module\Di\Code\Generator\Interceptor',
                ]
            ]
        );
        $configuration = $this->interceptionConfigurationBuilder->getInterceptionConfiguration($classesList);
        $generator->generateList($configuration);
    }
Ejemplo n.º 2
0
 public function testGetCodes()
 {
     $areas = ['area1' => 'value1', 'area2' => 'value2'];
     $this->_model = new \Magento\Framework\App\AreaList($this->objectManagerMock, $this->_resolverFactory, $areas, '');
     $expected = array_keys($areas);
     $actual = $this->_model->getCodes();
     $this->assertEquals($expected, $actual);
 }
Ejemplo n.º 3
0
 /**
  * Get options in "key-value" format
  *
  * @return array
  */
 public function toArray()
 {
     $areListCodes = $this->areaList->getCodes();
     $areList = [];
     foreach ($areListCodes as $areListCode) {
         $areList[$areListCode] = sprintf('%s [%s]', $this->areaList->getFrontName($areListCode), $areListCode);
     }
     return $areList;
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function doOperation()
 {
     if (empty($this->data)) {
         return;
     }
     $definitionsCollection = new DefinitionsCollection();
     foreach ($this->data as $path) {
         $definitionsCollection->addCollection($this->getDefinitionsCollection($path));
     }
     $areaCodes = array_merge([App\Area::AREA_GLOBAL], $this->areaList->getCodes());
     foreach ($areaCodes as $areaCode) {
         $this->configWriter->write($areaCode, $this->configReader->generateCachePerScope($definitionsCollection, $areaCode));
     }
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function doOperation()
 {
     if (empty($this->data)) {
         return;
     }
     $this->interceptionConfigurationBuilder->addAreaCode(App\Area::AREA_GLOBAL);
     foreach ($this->areaList->getCodes() as $areaCode) {
         $this->interceptionConfigurationBuilder->addAreaCode($areaCode);
     }
     $generatorIo = new \Magento\Framework\Code\Generator\Io(new \Magento\Framework\Filesystem\Driver\File(), $this->data);
     $generator = new \Magento\Tools\Di\Code\Generator($generatorIo, [Interceptor::ENTITY_TYPE => 'Magento\\Tools\\Di\\Code\\Generator\\Interceptor']);
     $configuration = $this->interceptionConfigurationBuilder->getInterceptionConfiguration(get_declared_classes());
     $generator->generateList($configuration);
 }
Ejemplo n.º 6
0
 public function testGetFrontNameWhenAreaCodeAndFrontNameArentSet()
 {
     $model = new \Magento\Framework\App\AreaList($this->objectManagerMock, $this->_resolverFactory);
     $code = 'testAreaCode';
     $this->assertNull($model->getCodeByFrontName($code));
     $this->assertNull($model->getFrontName($code));
     $this->assertSame([], $model->getCodes());
     $this->assertNull($model->getDefaultRouter($code));
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\App\\AreaInterface', ['areaCode' => $code])->willReturn('test');
     $this->assertSame('test', $model->getArea($code));
 }
Ejemplo n.º 7
0
 /**
  * Retrieve list of available config scopes
  *
  * @return string[]
  */
 public function getAllScopes()
 {
     $codes = $this->_areaList->getCodes();
     array_unshift($codes, $this->_defaultScope);
     return $codes;
 }