/**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var ConfigContext $context */
     /** @var array|null $definition */
     $definition = $context->getResult();
     if (empty($definition) || ConfigUtil::isExcludeAll($definition)) {
         // nothing to do
         return $definition;
     }
     $entityClass = $context->getClassName();
     if (!$this->doctrineHelper->isManageableEntityClass($entityClass)) {
         return $definition;
     }
     $expandRelations = $context->get(ExpandRelatedEntitiesConfigExtra::NAME);
     $associations = $this->doctrineHelper->getEntityMetadataForClass($entityClass)->getAssociationMappings();
     foreach ($associations as $fieldName => $mapping) {
         if (!$this->isAssociationCompletionRequired($fieldName, $definition)) {
             continue;
         }
         if (!in_array($fieldName, $expandRelations)) {
             continue;
         }
         $extras = array_filter($context->getExtras(), function ($item) {
             if ($item instanceof ExpandRelatedEntitiesConfigExtra || $item instanceof FilterFieldsConfigExtra) {
                 return false;
             }
             return true;
         });
         $config = $this->configProvider->getConfig($mapping['targetEntity'], $context->getVersion(), $context->getRequestType(), $extras);
         $definition[ConfigUtil::FIELDS][$fieldName] = $config;
     }
     $context->setResult([ConfigUtil::EXCLUSION_POLICY => ConfigUtil::EXCLUSION_POLICY_NONE, ConfigUtil::FIELDS => $definition[ConfigUtil::FIELDS]]);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var Context $context */
     $version = $context->getVersion();
     if (null === $version) {
         $context->setVersion(Version::LATEST);
     } elseif (0 === strpos($version, 'v')) {
         $context->setVersion(substr($version, 1));
     }
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var ConfigContext $context */
     if ($context->hasResult()) {
         // config is already set
         return;
     }
     $config = $this->loadConfig($context->getClassName(), $context->getVersion());
     if (null !== $config) {
         $context->setResult($config);
     }
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var MetadataContext $context */
     if ($context->hasResult()) {
         // config is already set
         return;
     }
     $config = $this->configBag->getMetadata($context->getClassName(), $context->getVersion());
     if (!empty($config)) {
         $context->setResult($config);
     }
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var RelationConfigContext $context */
     $config = $context->getResult();
     if (null !== $config) {
         // a config already exists
         return;
     }
     $config = $this->loadConfig($context->getClassName(), $context->getVersion());
     if (null !== $config) {
         $this->addConfigToContext($context, $config);
     }
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var ConfigContext $context */
     /** @var array|null $definition */
     $definition = $context->getResult();
     if (empty($definition) || ConfigUtil::isExcludeAll($definition)) {
         // nothing to normalize
         return;
     }
     if (ConfigUtil::getArrayValue($definition, ConfigUtil::DEFINITION)) {
         $definition = ConfigUtil::getArrayValue($definition, ConfigUtil::DEFINITION);
     }
     $fields = ConfigUtil::getArrayValue($definition, ConfigUtil::FIELDS);
     $entityClass = $context->getClassName();
     if ($this->doctrineHelper->isManageableEntityClass($entityClass)) {
         $fields = $this->completeDefinition($fields, $entityClass, $context->getVersion(), $context->getRequestType(), $context->getExtras());
     }
     $context->setResult([ConfigUtil::EXCLUSION_POLICY => ConfigUtil::EXCLUSION_POLICY_ALL, ConfigUtil::FIELDS => $fields]);
 }