getDefinition() public method

Gets the {@see EntityDefinition} instance.
public getDefinition ( ) : EntityDefinition
return EntityDefinition the definition instance
 /**
  * Postprocesses the entity after modification by handling the uploaded
  * files and setting the flash.
  *
  * @param Application $app
  * the current application
  * @param AbstractData $crudData
  * the data instance of the entity
  * @param Entity $instance
  * the entity
  * @param string $entity
  * the name of the entity
  * @param string $mode
  * whether to 'edit' or to 'create' the entity
  *
  * @return null|\Symfony\Component\HttpFoundation\RedirectResponse
  * the HTTP response of this modification
  */
 protected function modifyFilesAndSetFlashBag(Application $app, AbstractData $crudData, Entity $instance, $entity, $mode)
 {
     $id = $instance->get('id');
     $request = $app['request_stack']->getCurrentRequest();
     $result = $mode == 'edit' ? $crudData->updateFiles($request, $instance, $entity) : $crudData->createFiles($request, $instance, $entity);
     if (!$result) {
         return null;
     }
     $app['session']->getFlashBag()->add('success', $app['translator']->trans('crudlex.' . $mode . '.success', ['%label%' => $crudData->getDefinition()->getLabel(), '%id%' => $id]));
     return $app->redirect($app['url_generator']->generate('crudShow', ['entity' => $entity, 'id' => $id]));
 }
Beispiel #2
0
 /**
  * Performs the regular unique validation.
  *
  * @param $value
  * the value to validate
  * @param $data
  * the data instance to validate with
  * @param $entity
  * the entity of the field
  * @param $field
  * the field to validate
  *
  * @return boolean
  * true if everything is valid
  */
 protected function isValidUnique($value, AbstractData $data, Entity $entity, $field)
 {
     $params = [$field => $value];
     $paramsOperators = [$field => '='];
     if ($entity->get('id') !== null) {
         $params['id'] = $entity->get('id');
         $paramsOperators['id'] = '!=';
     }
     $amount = intval($data->countBy($data->getDefinition()->getTable(), $params, $paramsOperators, true));
     return $amount == 0;
 }