示例#1
0
 /**
  * @param WritableBearerInterface $fieldBearer
  * @param integer                 $countBegin
  * @return void
  */
 protected function suffixFieldBearerFields(WritableBearerInterface $fieldBearer, $countBegin = 0)
 {
     /** @var \Athens\Core\Field\FieldInterface $writable */
     foreach (array_values($fieldBearer->getWritables()) as $count => $writable) {
         if ($writable instanceof FieldInterface) {
             $writable->addSuffix($countBegin + $count);
         }
     }
 }
 /**
  * @return WritableInterface[]
  */
 public function getWritables()
 {
     return $this->writableBearer->getWritables();
 }
示例#3
0
 /**
  * Render $writableBearer into html.
  *
  * This method is generally called via double-dispatch, as provided by Visitor\VisitableTrait.
  *
  * @param WritableBearerInterface $writableBearer
  * @return string
  */
 public function visitWritableBearer(WritableBearerInterface $writableBearer)
 {
     $template = 'writable-bearer/' . $writableBearer->getType() . '.twig';
     return $this->loadTemplate($template)->render(["id" => $writableBearer->getId(), "classes" => $writableBearer->getClasses(), "data" => $writableBearer->getData(), "writables" => $writableBearer->getWritables()]);
 }
示例#4
0
 /**
  * @param WritableBearerInterface $writableBearer
  * @return void
  */
 protected function modifyFields(WritableBearerInterface $writableBearer)
 {
     foreach ($this->initialFieldValues as $fieldName => $value) {
         $writableBearer->getWritableByHandle($fieldName)->setInitial($value);
     }
     foreach ($this->fieldLabels as $fieldName => $label) {
         $writableBearer->getWritableByHandle($fieldName)->setLabel($label);
     }
     foreach ($this->fieldChoices as $fieldName => $choices) {
         $field = $writableBearer->getWritableByHandle($fieldName);
         $field->setType(FieldBuilder::TYPE_CHOICE);
         $field->setChoices($choices);
     }
     foreach ($this->fieldTypes as $fieldName => $type) {
         $field = $writableBearer->getWritableByHandle($fieldName);
         $field->setType($type);
     }
     foreach ($this->fieldHelptexts as $fieldName => $helptext) {
         $field = $writableBearer->getWritableByHandle($fieldName);
         $field->setHelptext($helptext);
     }
     foreach ($this->fieldPlaceholders as $fieldName => $placeholder) {
         $field = $writableBearer->getWritableByHandle($fieldName);
         $field->setPlaceholder($placeholder);
     }
 }