Created
October 20, 2016 06:05
-
-
Save keevitaja/bbd9e26c8af6bfe4a83e4834c9ac8a86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acty\ClassifiedsModule; | |
use Acty\ClassifiedsModule\Advert\Form\AdvertFormBuilder; | |
use Acty\ClassifiedsModule\Advert\Form\PublicAdvertFormBuilder; | |
use Acty\ClassifiedsModule\Entry\Form\EntryFormBuilder; | |
use Acty\ClassifiedsModule\Type\Contract\TypeRepositoryInterface; | |
use Anomaly\Streams\Platform\Addon\Plugin\Plugin; | |
use Twig_SimpleFunction; | |
class AdvertModulePlugin extends Plugin | |
{ | |
public function getFunctions() | |
{ | |
return [ | |
new Twig_SimpleFunction('advertForm', function() { | |
$builder = app(PublicAdvertFormBuilder::class); | |
$type = app(TypeRepositoryInterface::class); | |
$advert = app(AdvertFormBuilder::class); | |
$entry = app(EntryFormBuilder::class); | |
//$advert->setSkips(array_merge($advert->getSkips(), ['user'])); | |
//$advert->setFields(['user', 'description']); | |
$type = $type->find(1); | |
$builder->addForm('advert', $advert->setType($type)); | |
$builder->addForm('entry', $entry->setModel($type->getEntryModelName())); | |
$builder->make(); | |
// dd($builder->getFormFields()[0]->config); | |
return $builder->getFormPresenter(); | |
}, ['is_safe' => ['html']]) | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment