当前位置: 首页>>代码示例>>PHP>>正文


PHP ServiceManager::get方法代码示例

本文整理汇总了PHP中Zend\ServiceManager\ServiceManager::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceManager::get方法的具体用法?PHP ServiceManager::get怎么用?PHP ServiceManager::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\ServiceManager\ServiceManager的用法示例。


在下文中一共展示了ServiceManager::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: email

 /**
  * @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;
 }
开发者ID:zfury,项目名称:cmf,代码行数:10,代码来源:EditInputFilter.php

示例2: check

 /**
  * 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;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:37,代码来源:GenerationDirectoryAccess.php

示例3: setUp

 /**
  * {@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();
 }
开发者ID:debranova,项目名称:program,代码行数:35,代码来源:DoaLinkTest.php

示例4: email

 /**
  * @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;
 }
开发者ID:zfury,项目名称:cmf,代码行数:10,代码来源:Create.php

示例5: setUp

 /**
  * 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');
 }
开发者ID:esase,项目名称:dream-cms,代码行数:10,代码来源:AclTest.php

示例6: generateCertificate

 /**
  * 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;
 }
开发者ID:gsokolowski,项目名称:learnzf2,代码行数:33,代码来源:Pdf.php

示例7: setUp

 /**
  * 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');
 }
开发者ID:esase,项目名称:dream-cms,代码行数:10,代码来源:ApplicationSlugTest.php

示例8: setUp

 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();
 }
开发者ID:jaztec,项目名称:jaztec-acl,代码行数:28,代码来源:AclTest.php

示例9: testReturnsTranslatorBasedOnConfigurationWhenNoTranslatorInterfaceServicePresentWithMinimumBootstrap

 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());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:26,代码来源:TranslatorServiceFactoryTest.php

示例10: init

 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');
 }
开发者ID:Waldz,项目名称:ExampleZF2Application,代码行数:30,代码来源:Bootstrap.php

示例11: testAskingTwiceTheSameQueueReturnsTheSameInstance

 public function testAskingTwiceTheSameQueueReturnsTheSameInstance()
 {
     $queuePluginManager = $this->serviceManager->get('SlmQueue\\Queue\\QueuePluginManager');
     $firstInstance = $queuePluginManager->get('basic-queue');
     $secondInstance = $queuePluginManager->get('basic-queue');
     $this->assertSame($firstInstance, $secondInstance);
 }
开发者ID:jackdpeterson,项目名称:SlmQueue,代码行数:7,代码来源:QueuePluginManagerTest.php

示例12: create

 /**
  * @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;
 }
开发者ID:Tribalx,项目名称:Wizard,代码行数:11,代码来源:FormFactory.php

示例13: indexAction

 public function indexAction()
 {
     $requestUri = $this->getEvent()->getRouteMatch()->getParam('asset');
     $response = $this->serviceLocator->get('AssetsManager')->dispatch($requestUri);
     $this->getEvent()->setResponse($response);
     return $response;
 }
开发者ID:robertdamoc,项目名称:zf2-module-assets,代码行数:7,代码来源:AssetsController.php

示例14: setUp

 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);
 }
开发者ID:tck,项目名称:zf2-imageresizer,代码行数:7,代码来源:ImageProcessingTest.php

示例15: setUp

 /**
  * {@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();
 }
开发者ID:debranova,项目名称:program,代码行数:31,代码来源:CallLinkTest.php


注:本文中的Zend\ServiceManager\ServiceManager::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。