Пример #1
0
 /**
  * Load the parent model for the current list.
  *
  * @param InputProviderInterface $input       The input provider.
  *
  * @param EnvironmentInterface   $environment The environment.
  *
  * @return ModelInterface|null
  */
 protected function loadParentModel(InputProviderInterface $input, EnvironmentInterface $environment)
 {
     if (!$input->hasParameter('pid')) {
         return null;
     }
     $pid = ModelId::fromSerialized($input->getParameter('pid'));
     if (!($dataProvider = $environment->getDataProvider($pid->getDataProviderName()))) {
         return null;
     }
     if ($parent = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($pid->getId()))) {
         return $parent;
     }
     return null;
 }
Пример #2
0
 /**
  * Obtain the parameter with the given name from the input provider if it exists.
  *
  * @param InputProviderInterface $input The input provider.
  * @param string                 $name  The parameter to retrieve.
  *
  * @return ModelId|null
  */
 private function modelIdFromParameter(InputProviderInterface $input, $name)
 {
     if ($input->hasParameter($name) && ($value = $input->getParameter($name))) {
         return ModelId::fromSerialized($value);
     }
     return null;
 }