本文整理汇总了PHP中Zend\Form\FormInterface::getObject方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::getObject方法的具体用法?PHP FormInterface::getObject怎么用?PHP FormInterface::getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::getObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePost
public function updatePost(FormInterface $form)
{
$post = $form->getObject();
$this->assertGranted('blog.post.update', $post);
$this->bind($post, $form);
$this->objectManager->persist($post);
$this->getEventManager()->trigger('update', $this, ['post' => $post]);
}
示例2: fileCountValidationCallback
/**
* Callback for file count validation.
*
* @internal
* This function gets the value passed in as variable,
* but we do not need it.
* @return bool
*/
public function fileCountValidationCallback()
{
if ($this->form && ($object = $this->form->getObject())) {
if ($this->getMaxFileCount() - 1 < count($object)) {
return false;
}
}
return true;
}
示例3: editPageRepository
public function editPageRepository(FormInterface $form)
{
$page = $form->getObject();
if (!$form->isValid()) {
throw new RuntimeException(print_r($form->getMessages(), true));
}
$data = $form->getData(FormInterface::VALUES_AS_ARRAY);
$formClone = clone $form;
$formClone->bind($page);
$formClone->setData($data);
$formClone->isValid();
$this->assertGranted('page.update', $page);
$this->getObjectManager()->persist($page);
return $page;
}
示例4: updateParameter
/**
* @param FormInterface $form
* @return void
* @throws RuntimeException
*/
public function updateParameter(FormInterface $form)
{
$object = $form->getObject();
$this->assertGranted('navigation.manage', $object);
if (!$form->isValid()) {
throw new RuntimeException(print_r($form->getMessages()));
}
$this->objectManager->persist($object);
$this->getEventManager()->trigger('parameter.update', $this);
}
示例5: openTag
/**
* {@inheritDoc}
*/
public function openTag(FormInterface $form = null)
{
if ($form) {
$class = $form->getAttribute('class');
if (strpos($class, $this->defaultClass) === false) {
$class = trim("{$class} {$this->defaultClass}");
}
if ($object = $form->getObject()) {
$className = str_replace(array_keys($this->classNameReplacements), array_values($this->classNameReplacements), get_class($object));
} else {
$className = get_class($form);
}
$parts = explode('\\', $className);
foreach ($parts as $part) {
$classes[] = strtolower($part);
if (count($classes) > 1) {
$class .= ' ' . implode('-', $classes);
}
}
$form->setAttribute('class', $class);
$formAttributes = $form->getAttributes();
if (!array_key_exists('id', $formAttributes) && $classes) {
$form->setAttribute('id', implode('-', $classes));
}
}
return parent::openTag($form);
}