Esempio n. 1
0
 /**
  * @return $this
  */
 protected function email()
 {
     $uniqueObjectValidator = new UniqueObject(['object_repository' => $this->sm->get('Doctrine\\ORM\\EntityManager')->getRepository('User\\Entity\\User'), 'fields' => ['email'], 'object_manager' => $this->sm->get('Doctrine\\ORM\\EntityManager'), 'use_context' => true]);
     $uniqueObjectValidator->setMessage('Email is already taken', UniqueObject::ERROR_OBJECT_NOT_UNIQUE);
     $this->add(array('name' => 'email', 'required' => true, 'validators' => array(array('name' => 'EmailAddress'), $uniqueObjectValidator), 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
     return $this;
 }
 /**
  * Check var/generation read and write access
  *
  * @return bool
  */
 public function check()
 {
     $initParams = $this->serviceManager->get(InitParamListener::BOOTSTRAP_PARAM);
     $filesystemDirPaths = isset($initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] : [];
     $directoryList = new DirectoryList(BP, $filesystemDirPaths);
     $generationDirectoryPath = $directoryList->getPath(DirectoryList::GENERATION);
     $driverPool = new DriverPool();
     $fileWriteFactory = new WriteFactory($driverPool);
     /** @var \Magento\Framework\Filesystem\DriverInterface $driver */
     $driver = $driverPool->getDriver(DriverPool::FILE);
     $directoryWrite = new Write($fileWriteFactory, $driver, $generationDirectoryPath);
     if ($directoryWrite->isExist()) {
         if ($directoryWrite->isDirectory() || $directoryWrite->isReadable()) {
             try {
                 $probeFilePath = $generationDirectoryPath . DIRECTORY_SEPARATOR . uniqid(mt_rand()) . 'tmp';
                 $fileWriteFactory->create($probeFilePath, DriverPool::FILE, 'w');
                 $driver->deleteFile($probeFilePath);
             } catch (\Exception $e) {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         try {
             $directoryWrite->create();
         } catch (\Exception $e) {
             return false;
         }
     }
     return true;
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->doa = new Doa();
     $this->doa->setId(1);
     $program = new Program();
     $program->setId(1);
     $program->setProgram('Program');
     $this->doa->setProgram($program);
     $organisation = new Organisation();
     $organisation->setId(1);
     $organisation->setOrganisation("Organisation");
     $this->doa->setOrganisation($organisation);
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->doa)) {
         $this->authorizeService->getAcl()->addResource($this->doa);
         $this->authorizeService->getAcl()->allow([], $this->doa, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Doa())) {
         $this->authorizeService->getAcl()->addResource(new Doa());
     }
     $this->authorizeService->getAcl()->allow([], new Doa(), []);
     $this->doaLink = $this->serviceManager->get('viewhelpermanager')->get('programDoaLink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Esempio n. 4
0
File: Create.php Progetto: zfury/cmf
 /**
  * @return $this
  */
 protected function email()
 {
     $recordExistsValidator = new UniqueObject(array('object_repository' => $this->sm->get('Doctrine\\ORM\\EntityManager')->getRepository('Test\\Entity\\Test'), 'object_manager' => $this->sm->get('Doctrine\\ORM\\EntityManager'), 'fields' => 'email', 'use_context' => true));
     $recordExistsValidator->setMessage('This email already in use', UniqueObject::ERROR_OBJECT_NOT_UNIQUE);
     $this->add(array('name' => 'email', 'required' => true, 'validators' => array(array('name' => 'EmailAddress'), $recordExistsValidator), 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
     return $this;
 }
Esempio n. 5
0
 /**
  * Setup
  */
 protected function setUp()
 {
     // get service manager
     $this->serviceLocator = AclBootstrap::getServiceLocator();
     // get acl model
     $this->aclModelBase = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('Acl\\Model\\AclBase');
 }
Esempio n. 6
0
 /**
  * Generates certificate of exellence and
  * triggers an event when the file is generated
  * @param \User\Model\Entity\User $user
  * @param string $examName
  */
 public function generateCertificate($user, $examName)
 {
     $config = $this->services->get('config');
     $pdf = PdfDocument::load($config['pdf']['exam_certificate']);
     // get the first page
     $page = $pdf->pages[0];
     // Extract the AdineKirnberg-Script font included in the PDF sample
     $font = $page->extractFont('AdineKirnberg-Script');
     $page->setFont($font, 80);
     // and write the name of the user with it
     $page->drawText($user->getName(), 200, 280);
     // after that use Time Bold to write the name of the exam
     $font = PdfFont::fontWithName(PdfFont::FONT_TIMES_BOLD);
     $page->setFont($font, 40);
     $page->drawText($examName, 200, 120);
     // We use the png image from the public/images folder
     $imageFile = 'public/images/zf2-logo.png';
     // get the right size to do some calculations
     $size = getimagesize($imageFile);
     // load the image
     $image = \ZendPdf\Image::imageWithPath($imageFile);
     $x = 580;
     $y = 440;
     // and finally draw the image
     $page->drawImage($image, $x, $y, $x + $size[0], $y + $size[1]);
     return $pdf;
 }
Esempio n. 7
0
 /**
  * Setup
  */
 protected function setUp()
 {
     // get service manager
     $this->serviceLocator = ApplicationBootstrap::getServiceLocator();
     // get base model instance
     $this->model = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('Application\\Model\\ApplicationBase');
 }
Esempio n. 8
0
 public function setUp()
 {
     Bootstrap::setUpAclDatabase();
     $em = Bootstrap::getServiceManager()->get('doctrine.entitymanager.orm_default');
     /* @var $em \Doctrine\ORM\EntityManager */
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->acl = $this->serviceManager->get('jaztec_acl_service')->getAcl();
     $resource1 = new \JaztecAcl\Entity\Acl\Resource('resource01');
     $resource2 = new \JaztecAcl\Entity\Acl\Resource('resource02', $resource1);
     $resource3 = new \JaztecAcl\Entity\Acl\Resource('resource03', $resource2);
     $resource4 = new \JaztecAcl\Entity\Acl\Resource('resource04');
     $resource5 = new \JaztecAcl\Entity\Acl\Resource('resource05', $resource4);
     $privilege1 = new \JaztecAcl\Entity\Acl\Privilege();
     $privilege1->setResource($resource5);
     $privilege1->setRole($em->getRepository('JaztecAcl\\Entity\\Acl\\Role')->findOneBy(['name' => 'guest']));
     $privilege1->setType('allow');
     $em->persist($privilege1);
     $em->persist($resource1);
     $em->persist($resource2);
     $em->persist($resource3);
     $em->persist($resource4);
     $em->persist($resource5);
     $em->flush();
     // Clear the ACL.
     $this->acl->removeResourceAll();
     $this->acl->removeRoleAll();
     $this->acl->setupAcl();
 }
 public function testReturnsTranslatorBasedOnConfigurationWhenNoTranslatorInterfaceServicePresentWithMinimumBootstrap()
 {
     if (!extension_loaded('intl')) {
         $this->markTestSkipped('This test will only run if ext/intl is present');
     }
     //minimum bootstrap
     $applicationConfig = array('module_listener_options' => array(), 'modules' => array());
     $serviceLocator = new ServiceManager(new ServiceManagerConfig());
     $serviceLocator->setService('ApplicationConfig', $applicationConfig);
     $serviceLocator->get('ModuleManager')->loadModules();
     $serviceLocator->get('Application')->bootstrap();
     //enable to re-write Config
     $ref = new \ReflectionObject($serviceLocator);
     $prop = $ref->getProperty('allowOverride');
     $prop->setAccessible(true);
     $prop->setValue($serviceLocator, true);
     $config = array('di' => array(), 'translator' => array('locale' => 'en_US'));
     $serviceLocator->setService('Config', $config);
     //#5959
     //get any plugins with AbstractPluginManagerFactory
     $routePluginManagerFactory = new RoutePluginManagerFactory();
     $routePluginManager = $routePluginManagerFactory->createService($serviceLocator);
     $translator = $this->factory->createService($serviceLocator);
     $this->assertInstanceOf('Zend\\Mvc\\I18n\\Translator', $translator);
     $this->assertInstanceOf('Zend\\I18n\\Translator\\Translator', $translator->getTranslator());
 }
Esempio n. 10
0
 public static function init()
 {
     // Define application environment (production|staging|testing|development)
     defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APP_ENV') ? getenv('APP_ENV') : 'testing');
     // Load the user-defined test configuration file, if it exists; otherwise, load
     if (is_readable(__DIR__ . '/TestConfig.php')) {
         $testConfig = (include __DIR__ . '/TestConfig.php');
     } else {
         $testConfig = (include __DIR__ . '/TestConfig.php.dist');
     }
     $zf2ModulePaths = array();
     if (isset($testConfig['module_listener_options']['module_paths'])) {
         $modulePaths = $testConfig['module_listener_options']['module_paths'];
         foreach ($modulePaths as $modulePath) {
             if ($path = static::findParentPath($modulePath)) {
                 $zf2ModulePaths[] = $path;
             }
         }
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
     static::initAutoloader();
     // use ModuleManager to load this module and it's dependencies
     $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     $serviceManager = new ServiceManager(new ServiceManagerConfig(isset($config['service_manager']) ? $config['service_manager'] : array()));
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     static::$application = $serviceManager->get('Application');
 }
 public function testAskingTwiceTheSameQueueReturnsTheSameInstance()
 {
     $queuePluginManager = $this->serviceManager->get('SlmQueue\\Queue\\QueuePluginManager');
     $firstInstance = $queuePluginManager->get('basic-queue');
     $secondInstance = $queuePluginManager->get('basic-queue');
     $this->assertSame($firstInstance, $secondInstance);
 }
Esempio n. 12
0
 /**
  * @param  ServiceLocatorInterface $serviceLocator
  * @return FormInterface
  */
 public function create()
 {
     $formElementManager = $this->serviceManager->get('FormElementManager');
     $form = new Form();
     $form->add($formElementManager->get('Wizard\\Form\\Element\\Button\\Previous'))->add($formElementManager->get('Wizard\\Form\\Element\\Button\\Next'))->add($formElementManager->get('Wizard\\Form\\Element\\Button\\Valid'))->add($formElementManager->get('Wizard\\Form\\Element\\Button\\Cancel'));
     return $form;
 }
 public function indexAction()
 {
     $requestUri = $this->getEvent()->getRouteMatch()->getParam('asset');
     $response = $this->serviceLocator->get('AssetsManager')->dispatch($requestUri);
     $this->getEvent()->setResponse($response);
     return $response;
 }
Esempio n. 14
0
 protected function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->fileSystem = vfsStream::setup('public', null, array('img' => array('test.jpg' => file_get_contents(__DIR__ . '/../../_files/test.jpg')), 'processed' => array()));
     $this->imagine = $this->serviceManager->get('TckImageResizerImagine');
     $this->imageProcessing = new ImageProcessing($this->imagine);
 }
Esempio n. 15
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->call = new Call();
     $this->call->setId(1);
     $this->call->setCall('This is the call');
     $program = new Program();
     $program->setProgram('This is the program');
     $this->call->setProgram($program);
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->call)) {
         $this->authorizeService->getAcl()->addResource($this->call);
         $this->authorizeService->getAcl()->allow([], $this->call, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Call())) {
         $this->authorizeService->getAcl()->addResource(new Call());
     }
     $this->authorizeService->getAcl()->allow([], new Call(), []);
     $this->callLink = $this->serviceManager->get('viewhelpermanager')->get('calllink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Esempio n. 16
0
 /**
  * @return $this
  */
 protected function username()
 {
     $recordExistsValidator = new NoObjectExists(array('object_repository' => $this->sm->get('Doctrine\\ORM\\EntityManager')->getRepository('User\\Entity\\User'), 'fields' => 'username'));
     $recordExistsValidator->setMessage('User with this email already exists', NoObjectExists::ERROR_OBJECT_FOUND);
     $this->add(array('name' => 'username', 'required' => true, 'validators' => array($recordExistsValidator, array('name' => 'StringLength', 'options' => array('min' => 3, 'max' => 100))), 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'))));
     return $this;
 }
Esempio n. 17
0
 /**
  * Constructor
  *
  * @param ServiceManager $serviceManager Service manager
  */
 public function __construct(ServiceManager $serviceManager)
 {
     $this->request = $serviceManager->get('Request');
     $this->response = $serviceManager->get('Response');
     $this->pluginManager = $serviceManager->get('ControllerPluginManager');
     $this->serviceManager = $serviceManager;
 }
 public function testAskingTwiceForTheSameJobReturnsDifferentInstances()
 {
     $jobPluginManager = $this->serviceManager->get('SlmQueue\\Job\\JobPluginManager');
     $firstInstance = $jobPluginManager->get('SlmQueueTest\\Asset\\SimpleJob');
     $secondInstance = $jobPluginManager->get('SlmQueueTest\\Asset\\SimpleJob');
     $this->assertNotSame($firstInstance, $secondInstance);
 }
Esempio n. 19
0
 /**
  * Sends the mail to user with info about successfull registration
  *
  * @param \User\Entity\User $user
  * @param string $password
  * @param string $siteName
  */
 public function noticeOfCreation(UserEntity $user, $password, $siteName, $actUrl = null)
 {
     $template = $this->storage->getByKey(2);
     $serverUrl = $this->serviceManager->get('ViewHelperManager')->get('serverUrl');
     $body = str_replace(array("[NAME]", "[SITENAME]", "[LOGINNAME]", "[PASSWORD]", "[SITEURL]", "[ACTIVATIONLINK]"), array($user->username, $siteName, $user->username, $password, $serverUrl(), sprintf('<a href="%s">%s</a>', $actUrl, $actUrl)), $template->emailBody);
     return $this->send($user->username, $template->emailSubject, $body);
 }
Esempio n. 20
0
 public function setUp()
 {
     parent::setup();
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->em = $this->serviceManager->get('Doctrine\\ORM\\EntityManager');
     $this->negocio = new AnexoNegocio($this->em);
 }
Esempio n. 21
0
 public function testEquals()
 {
     $ids = array("B004UMO24E", "B00B6U14XA", "B00HQ2N52K", "B00B8XYO9G", "B00L3S2LWS", "B00L3S2LWS", "c3d33ab7-5dc5-41e6-8d2a-0aadbcffb738", "B00NH3GL96", "B00EKH4FP0", "50d98962-9561-4028-9282-37191f8772e3", "B008TUNEFG", "B00GG0GKDO", "B00CO79BXO", "B00O6BO6O0", "B00NPO529C", "B00NPIB7Z6", "B00H6MMV20", "B00NPLNUQ2", "B00NPLNRWY", "B00O5NGFBQ", "B00FXYJ568", "B005K00TLU", "B00IJEFRSY", "B00JQ4KY5C", "B00IJEFRSY", "B00J6ZHEHC", "B00J6ZHEHC", "B00B9CFYBI", "e6bb95b8-6af6-4dc8-bcd8-c6950c0ab046", "B00N02YOJ8", "B00EDGGW54", "B00D83XPTE", "B00M4YVHLQ", "B00NAGZB4Q", "B00L7N451E", "B00N1Q6Z86", "B00O1AJBU0", "B00H377PVK", "B00JPXT2WK", "B005SG6ELU", "B00LWXT17C", "B00LWXT22G", "B00O09LGIW", "B00NEF3KNW", "B00NN7B7FE", "B00JJWLB4O", "B00HS0H41S", "B00JQQPEC8", "B00O1HTQ0I", "B00GS02S8S");
     $config = $this->getApplicationConfig()['amazon-apai'];
     $apaiIoWrapper = new ApaiIOWrapper($config);
     /*
        #     $result2 =  $apaiIoWrapper->getByASIN('B00EDGGW54', 'de');
               #      $result2 =  $apaiIoWrapper->getByASIN('B00N02YOJ8', 'de');
        #     $result =  $apaiIoWrapper->getByASIN('B00GS02S8S', 'de');
                     #$result2 =  $apaiIoWrapper->getByASIN('B00EDGGW54', 'de');
     */
     /**
      * @var $itemNotFoundService ItemNotFoundServiceInterface
      */
     $itemNotFoundService = $this->serviceManager->get(ItemNotFoundServiceInterface::class);
     $countryCode = 'de';
     $resultSet = $apaiIoWrapper->getByASINS($ids, $countryCode);
     $notFound = $apaiIoWrapper->getItemsNotFound();
     foreach ($notFound[$countryCode] as $item) {
         $itemNotFound = new ItemNotFound();
         $itemNotFound->setAsin($item);
         $itemNotFound->setSearchedDe(true);
         $itemNotFoundService->getEntityManager()->persist($itemNotFound);
     }
     $itemNotFoundService->getEntityManager()->flush();
     $break = true;
 }
Esempio n. 22
0
 public function setUp()
 {
     $this->serviceManager = ServiceManagerFactory::getServiceManager();
     /* @var $application \Zend\Mvc\Application */
     $application = $this->serviceManager->get('Application');
     $application->bootstrap();
 }
 /**
  * @expectedException \HumusAmqpModule\Exception\InvalidArgumentException
  * @expectedExceptionMessage The logger invalid stuff is not configured
  */
 public function testCreateConsumerThrowsExceptionOnInvalidLogger()
 {
     $config = $this->services->get('Config');
     $config['humus_amqp_module']['rpc_servers']['test-rpc-server']['logger'] = 'invalid stuff';
     $this->services->setService('Config', $config);
     $this->components->createServiceWithName($this->services, 'test-rpc-server', 'test-rpc-server');
 }
Esempio n. 24
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->program = new Program();
     $this->program->setId(1);
     $this->program->setProgram('This is the program');
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->program)) {
         $this->authorizeService->getAcl()->addResource($this->program);
         $this->authorizeService->getAcl()->allow([], $this->program, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Program())) {
         $this->authorizeService->getAcl()->addResource(new Program());
     }
     $this->authorizeService->getAcl()->allow([], new Program(), []);
     $this->programLink = $this->serviceManager->get('viewhelpermanager')->get('programlink');
     $routeMatch = new RouteMatch(['program' => 1]);
     $routeMatch->setMatchedRouteName('route-program_entity_program');
     $this->programLink->setRouteMatch($routeMatch);
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Esempio n. 25
0
    /**
     * Sends award certificate
     *
     * @param \User\Model\Entity\User $user
     * @param array $exam
     * @param \ZendPdf\Document $pdf
     */
    public function sendCertificate($user, $exam, $pdf)
    {
        $translator = $this->services->get('translator');
        $mail = new Message();
        $mail->addTo($user->getEmail(), $user->getName());
        $text = 'You are genius!
You answered all the questions correctly.
Therefore we are sending you as a gratitude this free award certificate.

';
        // we create a new mime message
        $mimeMessage = new MimeMessage();
        // create the original body as part
        $textPart = new MimePart($text);
        $textPart->type = "text/plain";
        // add the pdf document as a second part
        $pdfPart = new MimePart($pdf->render());
        $pdfPart->type = 'application/pdf';
        $mimeMessage->setParts(array($textPart, $pdfPart));
        $mail->setBody($mimeMessage);
        $mail->setFrom('*****@*****.**', 'Slavey Karadzhov');
        $mail->setSubject($translator->translate('Congratulations: Here is your award certificate'));
        $transport = $this->services->get('mail-transport');
        $transport->send($mail);
    }
 protected function setUp()
 {
     $this->container = (include './config/container.php');
     $this->log = $this->container->get('tick_log_datastore');
     $this->log->deleteAll();
     $this->initCallback();
 }
Esempio n. 27
0
 /**
  * Setup
  */
 protected function setUp()
 {
     // get service manager
     $this->serviceLocator = FileManagerBootstrap::getServiceLocator();
     // get base user model instance
     $this->userModel = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('User\\Model\\UserBase');
 }
Esempio n. 28
0
 protected function setUpController(\Zend\Mvc\Controller\AbstractActionController $controller)
 {
     $config = (include 'config/application.config.php');
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     $serviceManager->setAllowOverride(true);
     $this->controller = $controller;
     $this->request = new Request();
     $this->response = new Response();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = new MvcEvent();
     $this->event->setRequest($this->request)->setResponse($this->response);
     $config = $serviceManager->get('Config');
     $routerConfig = isset($config['router']) ? $config['router'] : array();
     $router = HttpRouter::factory($routerConfig);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($serviceManager);
     $this->setupForwardPlugin();
     $this->setupParamsPlugin();
     $this->setupFormPlugin();
     $this->setupGridControllerPlugin();
     $this->setupControllerFilePlugin();
 }
Esempio n. 29
0
 /**
  * Handle layout titles onDispatch.
  *
  * @param MvcEvent $event
  */
 public function setTitleAndTranslation(MvcEvent $event)
 {
     $route = $event->getRouteMatch();
     $title = $this->service->get('ControllerPluginManager')->get('systemsettings');
     $viewHelper = $this->service->get('ViewHelperManager');
     $lang = new Container('translations');
     $translator = $this->service->get('translator');
     /*
      * Load translations.
      */
     $renderer = $this->service->get('ViewManager')->getRenderer();
     $renderer->plugin('formRow')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formCollection')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formLabel')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formSelect')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formSubmit')->setTranslator($translator, 'SD_Translations');
     AbstractValidator::setDefaultTranslator($translator, 'formandtitle');
     $translator->setLocale($lang->offsetGet('languageName'))->setFallbackLocale('en');
     $viewModel = $event->getViewModel();
     $viewModel->setVariable('lang', $translator->getLocale());
     /*
      * Custom flash messenger.
      */
     $msg = $lang->offsetGet('flashMessages');
     $viewModel->setVariable('flashMessages', $msg);
     /*
      * Load page title
      */
     $action = $route->getParam('post') ? ' - ' . $route->getParam('post') : ucfirst($route->getParam('__CONTROLLER__'));
     $headTitleHelper = $viewHelper->get('headTitle');
     $headTitleHelper->append($title->__invoke('general', 'site_name') . ' ' . $action);
 }
Esempio n. 30
0
 public static function init()
 {
     // Load the user-defined test configuration file, if it exists; otherwise, load
     if (is_readable(__DIR__ . '/application.config.php')) {
         $testConfig = (include __DIR__ . '/application.config.php');
     } else {
         $testConfig = (include __DIR__ . '/application.config.php.dist');
     }
     chdir(__DIR__ . '/..');
     $zf2ModulePaths = array();
     if (isset($testConfig['module_listener_options']['module_paths'])) {
         $modulePaths = $testConfig['module_listener_options']['module_paths'];
         foreach ($modulePaths as $modulePath) {
             if ($path = static::findParentPath($modulePath)) {
                 $zf2ModulePaths[] = $path;
             }
         }
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
     static::initAutoloader();
     // use ModuleManager to load this module and it's dependencies
     $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     $entityManager = $serviceManager->get('doctrine.entitymanager.orm_default');
     $eventManager = $entityManager->getEventManager();
     $eventManager->addEventSubscriber(new \Aaa\EntityEvents\PrePersistListener(null));
     static::$eventManager = $eventManager;
     static::$serviceManager = $serviceManager;
     static::$config = $config;
     // static::createSchemaFromEntities();
 }