コード例 #1
0
 /**
  * Convert dom node tree to array
  *
  * @param \DOMDocument $source
  * @return array
  * @throws \InvalidArgumentException
  */
 public function convert($source)
 {
     $output = ['entities' => []];
     /** @var \DOMNodeList $entities */
     $entities = $source->getElementsByTagName('entity');
     /** @var \DOMNode $entityConfig */
     foreach ($entities as $entityConfig) {
         $attributes = $entityConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $label = $attributes->getNamedItem('label')->nodeValue;
         $behaviorModel = $attributes->getNamedItem('behaviorModel')->nodeValue;
         $model = $attributes->getNamedItem('model')->nodeValue;
         if (!$this->moduleManager->isOutputEnabled(Classes::getClassModuleName($model))) {
             continue;
         }
         $output['entities'][$name] = ['name' => $name, 'label' => $label, 'behaviorModel' => $behaviorModel, 'model' => $model, 'types' => [], 'relatedIndexers' => []];
     }
     /** @var \DOMNodeList $entityTypes */
     $entityTypes = $source->getElementsByTagName('entityType');
     /** @var \DOMNode $entityTypeConfig */
     foreach ($entityTypes as $entityTypeConfig) {
         $attributes = $entityTypeConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $model = $attributes->getNamedItem('model')->nodeValue;
         $entity = $attributes->getNamedItem('entity')->nodeValue;
         if (isset($output['entities'][$entity])) {
             $output['entities'][$entity]['types'][$name] = ['name' => $name, 'model' => $model];
         }
     }
     /** @var \DOMNodeList $relatedIndexers */
     $relatedIndexers = $source->getElementsByTagName('relatedIndexer');
     /** @var \DOMNode $relatedIndexerConfig */
     foreach ($relatedIndexers as $relatedIndexerConfig) {
         $attributes = $relatedIndexerConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $entity = $attributes->getNamedItem('entity')->nodeValue;
         if (isset($output['entities'][$entity])) {
             $output['entities'][$entity]['relatedIndexers'][$name] = ['name' => $name];
         }
     }
     return $output;
 }
コード例 #2
0
 /**
  * Convert dom node tree to array
  *
  * @param \DOMDocument $source
  * @return array
  * @throws \InvalidArgumentException
  */
 public function convert($source)
 {
     $output = ['entities' => [], 'fileFormats' => []];
     /** @var \DOMNodeList $entities */
     $entities = $source->getElementsByTagName('entity');
     /** @var \DOMNode $entityConfig */
     foreach ($entities as $entityConfig) {
         $attributes = $entityConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $label = $attributes->getNamedItem('label')->nodeValue;
         $model = $attributes->getNamedItem('model')->nodeValue;
         if (!$this->moduleManager->isOutputEnabled(Classes::getClassModuleName($model))) {
             continue;
         }
         $entityAttributeFilterType = $attributes->getNamedItem('entityAttributeFilterType')->nodeValue;
         $output['entities'][$name] = ['name' => $name, 'label' => $label, 'model' => $model, 'types' => [], 'entityAttributeFilterType' => $entityAttributeFilterType];
     }
     /** @var \DOMNodeList $entityTypes */
     $entityTypes = $source->getElementsByTagName('entityType');
     /** @var \DOMNode $entityTypeConfig */
     foreach ($entityTypes as $entityTypeConfig) {
         $attributes = $entityTypeConfig->attributes;
         $model = $attributes->getNamedItem('model')->nodeValue;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $entity = $attributes->getNamedItem('entity')->nodeValue;
         if (isset($output['entities'][$entity])) {
             $output['entities'][$entity]['types'][$name] = ['name' => $name, 'model' => $model];
         }
     }
     /** @var \DOMNodeList $fileFormats */
     $fileFormats = $source->getElementsByTagName('fileFormat');
     /** @var \DOMNode $fileFormatConfig */
     foreach ($fileFormats as $fileFormatConfig) {
         $attributes = $fileFormatConfig->attributes;
         $name = $attributes->getNamedItem('name')->nodeValue;
         $model = $attributes->getNamedItem('model')->nodeValue;
         $label = $attributes->getNamedItem('label')->nodeValue;
         $output['fileFormats'][$name] = ['name' => $name, 'model' => $model, 'label' => $label];
     }
     return $output;
 }
コード例 #3
0
 /**
  * Validate plugin interface
  *
  * @param string $plugin
  * @param string $type
  */
 protected function validatePlugins($plugin, $type)
 {
     try {
         $module = \Magento\Framework\App\Utility\Classes::getClassModuleName($type);
         if (\Magento\Framework\App\Utility\Files::init()->isModuleExists($module)) {
             $this->pluginValidator->validate($plugin, $type);
         }
     } catch (\Magento\Framework\Interception\Code\ValidatorException $exception) {
         $this->fail($exception->getMessage());
     }
 }