public function getPreviousValidSibling($linkType, EntityInterface $following) { $children = $this->getChildren($linkType, $following->getType()->getName()); if (($index = $children->indexOf($following)) === false) { return null; } for ($i = $index - 1; $i >= 0; --$i) { $child = $children->get($i); if ($child->hasCurrentRevision() && !$child->isTrashed()) { return $child; } } return null; }
/** * @param EntityInterface $entity * @return Form */ protected function getForm(EntityInterface $entity, $id = null) { // Todo: Unhack $type = $entity->getType()->getName(); $form = $this->moduleOptions->getType($type)->getComponent('repository')->getForm(); $form = $this->getServiceLocator()->get($form); $revision = $this->getRevision($entity, $id); if (is_object($revision)) { $data = []; foreach ($revision->getFields() as $field) { $data[$field->getName()] = $field->getValue(); } $form->setData($data); } $license = $entity->getLicense(); $agreement = $license->getAgreement() ? $license->getAgreement() : $license->getTitle(); $form->get('license')->get('agreement')->setLabel($agreement); $form->get('changes')->setValue(''); return $form; }
public function getOptions(EntityInterface $entity) { return $this->getModuleOptions()->getType($entity->getType()->getName()); }