コード例 #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
 /**
  * Generate the form.
  *
  * @return array
  */
 private function generateForm()
 {
     $fields = array();
     // Loop over all attributes now.
     foreach ($this->metaModel->getAttributes() as $attribute) {
         $attrId = $attribute->get('id');
         if (!$this->accepts($attribute)) {
             continue;
         }
         if ($this->knowsAttribute($attribute)) {
             if ($this->input->hasValue('attribute_' . $attrId)) {
                 $fields[] = array('checkbox' => false, 'text' => $this->translator->translate('addAll_addsuccess', static::$table, array($attribute->getName())), 'class' => 'tl_confirm', 'attr_id' => $attrId);
                 continue;
             }
             $fields[] = array('checkbox' => false, 'text' => $this->translator->translate('addAll_alreadycontained', static::$table, array($attribute->getName())), 'class' => 'tl_info', 'attr_id' => $attrId);
             continue;
         }
         $fields[] = array('checkbox' => true, 'text' => $this->translator->translate('addAll_willadd', static::$table, array($attribute->getName())), 'class' => 'tl_new', 'attr_id' => $attrId);
         $this->template->hasCheckbox = true;
     }
     return $fields;
 }
コード例 #3
0
ファイル: PasteHandler.php プロジェクト: zonky2/dc-general
 /**
  * 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;
 }
コード例 #4
0
 /**
  * Handle paste after.
  *
  * @param InputProviderInterface $input      The input provider.
  *
  * @param ControllerInterface    $controller The controller.
  *
  * @param ModelInterface         $model      The model.
  *
  * @return void
  */
 private function handleAfter(InputProviderInterface $input, ControllerInterface $controller, ModelInterface $model)
 {
     $after = ModelId::fromSerialized($input->getParameter('after'));
     $sibling = $controller->fetchModelFromProvider($after);
     if (!$sibling || $controller->isRootModel($sibling)) {
         $controller->setRootModel($model);
     } else {
         $parent = $controller->searchParentOf($sibling);
         $controller->setParent($model, $parent);
     }
 }
コード例 #5
0
ファイル: BreadCrumbBase.php プロジェクト: zonky2/core
 /**
  * Check if the given table is the current table.
  *
  * @param string                 $table The name of the table.
  *
  * @param InputProviderInterface $input The input provider in use.
  *
  * @return bool
  */
 protected function isActiveTable($table, InputProviderInterface $input)
 {
     return $input->getParameter('table') == $table;
 }