/**
  * Create a new field assignment.
  *
  * @param AssignmentFormBuilder     $builder
  * @param DiskRepositoryInterface   $disks
  * @param FieldRepositoryInterface  $fields
  * @param StreamRepositoryInterface $streams
  * @param                           $id
  * @param                           $field
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function create(AssignmentFormBuilder $builder, DiskRepositoryInterface $disks, FieldRepositoryInterface $fields, StreamRepositoryInterface $streams, $id, $field)
 {
     /* @var DiskInterface $disk */
     $disk = $disks->find($id);
     $stream = $streams->findBySlugAndNamespace($disk->getSlug(), 'files');
     return $builder->setOption('redirect', 'admin/files/disks/assignments/' . $id)->setField($fields->find($field))->setStream($stream)->render();
 }
 /**
  * Handle the form fields.
  *
  * @param AssignmentFormBuilder $builder
  */
 public function handle(AssignmentFormBuilder $builder)
 {
     $builder->setFields(['label' => ['label' => 'streams::assignment.label.name', 'instructions' => 'streams::assignment.label.instructions', 'type' => 'anomaly.field_type.text'], 'placeholder' => ['label' => 'streams::assignment.placeholder.name', 'instructions' => 'streams::assignment.placeholder.instructions', 'type' => 'anomaly.field_type.text'], 'instructions' => ['label' => 'streams::assignment.instructions.name', 'instructions' => 'streams::assignment.instructions.instructions', 'type' => 'anomaly.field_type.textarea'], 'warning' => ['label' => 'streams::assignment.warning.name', 'instructions' => 'streams::assignment.warning.instructions', 'type' => 'anomaly.field_type.text'], 'required' => ['label' => 'streams::assignment.required.label', 'instructions' => 'streams::assignment.required.instructions', 'type' => 'anomaly.field_type.boolean'], 'unique' => ['label' => 'streams::assignment.unique.label', 'instructions' => 'streams::assignment.unique.instructions', 'type' => 'anomaly.field_type.boolean'], 'translatable' => ['label' => 'streams::assignment.translatable.label', 'instructions' => 'streams::assignment.translatable.instructions', 'type' => 'anomaly.field_type.boolean', 'warning' => function (AssignmentFormBuilder $builder) {
         $type = $builder->getFieldType();
         return $type->getColumnType() == null ? 'streams::assignment.translatable.warning' : null;
     }, 'disabled' => function (AssignmentFormBuilder $builder) {
         $stream = $builder->getStream();
         if ($stream && !$stream->isTranslatable()) {
             return true;
         }
         $type = $builder->getFieldType();
         return $type->getColumnType() == null;
     }]]);
 }
 /**
  * Edit an existing assignment.
  *
  * @param AssignmentFormBuilder   $builder
  * @param TypeRepositoryInterface $types
  * @param                         $type
  * @param                         $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function edit(AssignmentFormBuilder $builder, TypeRepositoryInterface $types, $type, $id)
 {
     /* @var TypeInterface $type */
     $type = $types->find($type);
     return $builder->setStream($type->getEntryStream())->render($id);
 }
Example #4
0
 /**
  * Return a form for an existing post type field and assignment.
  *
  * @param AssignmentFormBuilder       $form
  * @param TypeRepositoryInterface     $types
  * @param BreadcrumbCollection        $breadcrumbs
  * @param                             $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function assignment(AssignmentFormBuilder $form, TypeRepositoryInterface $types, BreadcrumbCollection $breadcrumbs, $id, $assignment)
 {
     $type = $types->find($id);
     $breadcrumbs->put('module::breadcrumb.fields', 'admin/posts/types/fields/' . $type->getId());
     return $form->render($assignment);
 }
 /**
  * Return a form for an existing file type field and assignment.
  *
  * @param AssignmentFormBuilder       $form
  * @param FolderRepositoryInterface   $folders
  * @param                             $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function assignment(AssignmentFormBuilder $form, FolderRepositoryInterface $folders, $id, $assignment)
 {
     $folder = $folders->find($id);
     $this->breadcrumbs->put('streams::breadcrumb.assignments', 'admin/files/types/assignments/' . $folder->getId());
     return $form->render($assignment);
 }
 /**
  * Return a form for an existing page type field and assignment.
  *
  * @param AssignmentFormBuilder       $form
  * @param StreamRepositoryInterface   $streams
  * @param TypeRepositoryInterface     $types
  * @param BreadcrumbCollection        $breadcrumbs
  * @param                             $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function assignment(AssignmentFormBuilder $form, StreamRepositoryInterface $streams, TypeRepositoryInterface $types, BreadcrumbCollection $breadcrumbs, $id, $assignment)
 {
     $type = $types->find($id);
     $breadcrumbs->put('streams::breadcrumb.assignments', 'admin/pages/types/assignments/' . $type->getId());
     return $form->render($assignment);
 }