Example #1
0
 /**
  * Converts a value from its database representation to its PHP representation
  * of this type.
  *
  * @param mixed                                     $value    The value to convert.
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The currently used database platform.
  *
  * @return mixed The PHP representation of the value.
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     $file = new File($value, File::getDefaultBasePath());
     $file->setLoaded();
     return $file;
 }
 /**
  * Initialize listeners and annotations required for extensions
  *
  * @param MvcEvent $e
  *
  * @throws \Doctrine\DBAL\DBALException
  */
 public function initializeBitWebDoctrineExtensions(MvcEvent $e)
 {
     $locator = $e->getApplication()->getServiceManager();
     Type::addType('file', FileType::class);
     File::setDefaultBasePath(dirname($_SERVER['SCRIPT_FILENAME']) . '/files');
     File::setDefaultUploadBasePath(File::getDefaultBasePath());
     /* @var $em EntityManager */
     $em = $locator->get(EntityManager::class);
     $em->getConfiguration()->addFilter('SoftDelete', SoftDeleteFilter::class);
     $em->getFilters()->enable('SoftDelete');
     new FileListener($em->getEventManager());
     new IpListener($em->getEventManager());
     new SoftDeletableListener($em->getEventManager());
     new UserAgentListener($em->getEventManager());
     $annotationBaseDir = __DIR__ . '/../../../doctrine-extension/src/Mapping/';
     AnnotationRegistry::registerFile($annotationBaseDir . 'File.php');
     AnnotationRegistry::registerFile($annotationBaseDir . 'Ip.php');
     AnnotationRegistry::registerFile($annotationBaseDir . 'SoftDeletable.php');
     AnnotationRegistry::registerFile($annotationBaseDir . 'UserAgent.php');
 }