• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ServiceLocator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ServiceLocator的典型用法代码示例。如果您正苦于以下问题:PHP ServiceLocator类的具体用法?PHP ServiceLocator怎么用?PHP ServiceLocator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: __construct

 public function __construct(ServiceLocator $sl, $path)
 {
     $this->request = $sl->get('request');
     $this->response = $sl->get('response');
     $this->path = $path;
     // …
 }
开发者ID:robinstaes,项目名称:ws2-sws-course-materials,代码行数:7,代码来源:di_04.php


示例2: create

 /**
  * @return TestDbAcle;
  */
 public static function create(\Pdo $pdo, $factoryOverrides = array(), $factories = null)
 {
     if (is_null($factories)) {
         $factories = new Config\DefaultFactories();
     }
     $testDbAcle = new TestDbAcle();
     $serviceLocator = new ServiceLocator($factories->getFactories($pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)));
     $serviceLocator->addFactories($factoryOverrides);
     $serviceLocator->setService('pdo', $pdo);
     $testDbAcle->setServiceLocator($serviceLocator);
     return $testDbAcle;
 }
开发者ID:d1webtop,项目名称:test-db-acle,代码行数:15,代码来源:TestDbAcle.php


示例3: __construct

 public function __construct()
 {
     parent::__construct();
     $userRepository = new UserRepository();
     $user = ServiceLocator::GetServer()->GetUserSession();
     $this->_presenter = new ManageSchedulesPresenter($this, new ScheduleAdminManageScheduleService(new ScheduleAdminScheduleRepository($userRepository, $user), new ScheduleRepository(), new ResourceAdminResourceRepository($userRepository, $user)), new GroupRepository());
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:7,代码来源:ScheduleAdminManageSchedulesPage.php


示例4: PageLoad

 public function PageLoad()
 {
     ob_clean();
     $this->presenter->PageLoad();
     $config = Configuration::Instance();
     $feed = new FeedWriter(ATOM);
     $title = $config->GetKey(ConfigKeys::APP_TITLE);
     $feed->setTitle("{$title} Reservations");
     $url = $config->GetScriptUrl();
     $feed->setLink($url);
     $feed->setChannelElement('updated', date(DATE_ATOM, time()));
     $feed->setChannelElement('author', array('name' => $title));
     foreach ($this->reservations as $reservation) {
         /** @var FeedItem $item */
         $item = $feed->createNewItem();
         $item->setTitle($reservation->Summary);
         $item->setLink($reservation->ReservationUrl);
         $item->setDate($reservation->DateCreated->Timestamp());
         $item->setDescription($this->FormatReservationDescription($reservation, ServiceLocator::GetServer()->GetUserSession()));
         //			sprintf('<div><span>Start</span> %s</div>
         //										  <div><span>End</span> %s</div>
         //										  <div><span>Organizer</span> %s</div>
         //										  <div><span>Description</span> %s</div>',
         //										  $reservation->DateStart->ToString(),
         //										  $reservation->DateEnd->ToString(),
         //										  $reservation->Organizer,
         //										  $reservation->Description));
         $feed->addItem($item);
     }
     $feed->genarateFeed();
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:31,代码来源:AtomSubscriptionPage.php


示例5: GetList

 /**
  * Returns a limited query based on page number and size
  * If nulls are passed for both $pageNumber, $pageSize then all results are returned
  *
  * @param SqlCommand $command
  * @param callback $listBuilder callback to for each row of results
  * @param int|null $pageNumber
  * @param int|null $pageSize
  * @param string|null $sortField
  * @param string|null $sortDirection
  * @return PageableData
  */
 public static function GetList($command, $listBuilder, $pageNumber = null, $pageSize = null, $sortField = null, $sortDirection = null)
 {
     $total = null;
     $totalCounter = 0;
     $results = array();
     $db = ServiceLocator::GetDatabase();
     $pageNumber = intval($pageNumber);
     $pageSize = intval($pageSize);
     if (empty($pageNumber) && empty($pageSize) || $pageSize == PageInfo::All) {
         $resultReader = $db->Query($command);
     } else {
         $totalReader = $db->Query(new CountCommand($command));
         if ($row = $totalReader->GetRow()) {
             $total = $row[ColumnNames::TOTAL];
         }
         $pageNumber = empty($pageNumber) ? 1 : $pageNumber;
         $pageSize = empty($pageSize) ? 1 : $pageSize;
         $resultReader = $db->LimitQuery($command, $pageSize, ($pageNumber - 1) * $pageSize);
     }
     while ($row = $resultReader->GetRow()) {
         $results[] = call_user_func($listBuilder, $row);
         $totalCounter++;
     }
     $resultReader->Free();
     return new PageableData($results, is_null($total) ? $totalCounter : $total, $pageNumber, $pageSize);
 }
开发者ID:hugutux,项目名称:booked,代码行数:38,代码来源:PageableDataStore.php


示例6: __construct

 protected function __construct($titleKey = '', $pageDepth = 0)
 {
     $this->SetSecurityHeaders();
     $this->path = str_repeat('../', $pageDepth);
     $this->server = ServiceLocator::GetServer();
     $resources = Resources::GetInstance();
     ExceptionHandler::SetExceptionHandler(new WebExceptionHandler(array($this, 'RedirectToError')));
     $this->smarty = new SmartyPage($resources, $this->path);
     $userSession = ServiceLocator::GetServer()->GetUserSession();
     $this->smarty->assign('Charset', $resources->Charset);
     $this->smarty->assign('CurrentLanguage', $resources->CurrentLanguage);
     $this->smarty->assign('HtmlLang', $resources->HtmlLang);
     $this->smarty->assign('HtmlTextDirection', $resources->TextDirection);
     $appTitle = Configuration::Instance()->GetKey(ConfigKeys::APP_TITLE);
     $pageTile = $resources->GetString($titleKey);
     $this->smarty->assign('Title', (empty($appTitle) ? 'Booked' : $appTitle) . (empty($pageTile) ? '' : ' - ' . $pageTile));
     $this->smarty->assign('CalendarJSFile', $resources->CalendarLanguageFile);
     $this->smarty->assign('LoggedIn', $userSession->IsLoggedIn());
     $this->smarty->assign('Version', Configuration::VERSION);
     $this->smarty->assign('Path', $this->path);
     $this->smarty->assign('ScriptUrl', Configuration::Instance()->GetScriptUrl());
     $this->smarty->assign('UserName', !is_null($userSession) ? $userSession->FirstName : '');
     $this->smarty->assign('DisplayWelcome', $this->DisplayWelcome());
     $this->smarty->assign('UserId', $userSession->UserId);
     $this->smarty->assign('CanViewAdmin', $userSession->IsAdmin);
     $this->smarty->assign('CanViewGroupAdmin', $userSession->IsGroupAdmin);
     $this->smarty->assign('CanViewResourceAdmin', $userSession->IsResourceAdmin);
     $this->smarty->assign('CanViewScheduleAdmin', $userSession->IsScheduleAdmin);
     $this->smarty->assign('CanViewResponsibilities', !$userSession->IsAdmin && ($userSession->IsGroupAdmin || $userSession->IsResourceAdmin || $userSession->IsScheduleAdmin));
     $allowAllUsersToReports = Configuration::Instance()->GetSectionKey(ConfigSection::REPORTS, ConfigKeys::REPORTS_ALLOW_ALL, new BooleanConverter());
     $this->smarty->assign('CanViewReports', $allowAllUsersToReports || $userSession->IsAdmin || $userSession->IsGroupAdmin || $userSession->IsResourceAdmin || $userSession->IsScheduleAdmin);
     $timeout = Configuration::Instance()->GetKey(ConfigKeys::INACTIVITY_TIMEOUT);
     if (!empty($timeout)) {
         $this->smarty->assign('SessionTimeoutSeconds', max($timeout, 1) * 60);
     }
     $this->smarty->assign('ShouldLogout', $this->GetShouldAutoLogout());
     $this->smarty->assign('CssExtensionFile', Configuration::Instance()->GetKey(ConfigKeys::CSS_EXTENSION_FILE));
     $this->smarty->assign('UseLocalJquery', Configuration::Instance()->GetKey(ConfigKeys::USE_LOCAL_JQUERY, new BooleanConverter()));
     $this->smarty->assign('EnableConfigurationPage', Configuration::Instance()->GetSectionKey(ConfigSection::PAGES, ConfigKeys::PAGES_ENABLE_CONFIGURATION, new BooleanConverter()));
     $this->smarty->assign('ShowParticipation', !Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION, ConfigKeys::RESERVATION_PREVENT_PARTICIPATION, new BooleanConverter()));
     $this->smarty->assign('LogoUrl', 'booked.png');
     if (file_exists($this->path . 'img/custom-logo.png')) {
         $this->smarty->assign('LogoUrl', 'custom-logo.png');
     }
     if (file_exists($this->path . 'img/custom-logo.gif')) {
         $this->smarty->assign('LogoUrl', 'custom-logo.gif');
     }
     if (file_exists($this->path . 'img/custom-logo.jpg')) {
         $this->smarty->assign('LogoUrl', 'custom-logo.jpg');
     }
     $this->smarty->assign('CssUrl', 'null-style.css');
     if (file_exists($this->path . 'css/custom-style.css')) {
         $this->smarty->assign('CssUrl', 'custom-style.css');
     }
     $logoUrl = Configuration::Instance()->GetKey(ConfigKeys::HOME_URL);
     if (empty($logoUrl)) {
         $logoUrl = $this->path . Pages::UrlFromId($userSession->HomepageId);
     }
     $this->smarty->assign('HomeUrl', $logoUrl);
 }
开发者ID:ViraSoftware,项目名称:booked,代码行数:60,代码来源:Page.php


示例7: PageLoad

 public function PageLoad()
 {
     $this->Set('DefaultTitle', Resources::GetInstance()->GetString('NoTitleLabel'));
     $this->presenter->SetSearchCriteria(ServiceLocator::GetServer()->GetUserSession()->UserId, ReservationUserLevel::ALL);
     $this->presenter->PageLoad();
     $this->Display('upcoming_reservations.tpl');
 }
开发者ID:hugutux,项目名称:booked,代码行数:7,代码来源:UpcomingReservations.php


示例8: update

 /**
  * Update method to register message sending events.
  *
  * @access	public
  * @param $args['news_id'] Newsletter identifier refferring to the event.
  * * @param $args['msg_id'] Message identifier refferring to the event.
  * @return  false if something wrong.
  * @since	0.6
  */
 function update(&$args)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if (!isset($args['news_id']) || !isset($args['msg_id'])) {
         return false;
     }
     $news_id = (int) $args['news_id'];
     $msg_id = (int) $args['msg_id'];
     $dbo =& JFactory::getDBO();
     $query = 'UPDATE #__jinc_newsletter SET lastsent = now() ' . 'WHERE id = ' . (int) $news_id;
     $dbo->setQuery($query);
     $logger->debug('SentMsgEvent: executing query: ' . $query);
     if (!$dbo->query()) {
         $logger->error('SentMsgEvent: error updating last newsletter dispatch date');
         return false;
     }
     $query = 'UPDATE #__jinc_message SET datasent = now() ' . 'WHERE id = ' . (int) $msg_id;
     $dbo->setQuery($query);
     $logger->debug('SentMsgEvent: executing query: ' . $query);
     if (!$dbo->query()) {
         $logger->error('SentMsgEvent: error updating last message dispatch date');
         return false;
     }
     return true;
 }
开发者ID:madseller,项目名称:coperio,代码行数:36,代码来源:sentmsgevent.php


示例9: __construct

 public function __construct($user = null)
 {
     $this->user = $user;
     if ($this->user == null) {
         $this->user = ServiceLocator::GetServer()->GetUserSession();
     }
 }
开发者ID:ksdtech,项目名称:booked,代码行数:7,代码来源:SlotLabelFactory.php


示例10: setup

 function setup()
 {
     $this->_db = new FakeDatabase();
     ServiceLocator::SetDatabase($this->_db);
     $this->newEncryption = new PasswordEncryption();
     $this->oldEncryption = new RetiredPasswordEncryption();
 }
开发者ID:utn-frm-si,项目名称:booked,代码行数:7,代码来源:PasswordMigrationTests.php


示例11: __construct

 /**
  * @param IReservationViewRepository $reservationViewRepository
  * @param IReservationAuthorization $authorization
  * @param IReservationHandler $reservationHandler
  * @param IUpdateReservationPersistenceService $persistenceService
  */
 public function __construct(IReservationViewRepository $reservationViewRepository, $authorization = null, $reservationHandler = null, $persistenceService = null)
 {
     $this->reservationViewRepository = $reservationViewRepository;
     $this->reservationAuthorization = $authorization == null ? new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization()) : $authorization;
     $this->persistenceService = $persistenceService == null ? new UpdateReservationPersistenceService(new ReservationRepository()) : $persistenceService;
     $this->reservationHandler = $reservationHandler == null ? ReservationHandler::Create(ReservationAction::Update, $this->persistenceService, ServiceLocator::GetServer()->GetUserSession()) : $reservationHandler;
 }
开发者ID:hugutux,项目名称:booked,代码行数:13,代码来源:ManageReservationsService.php


示例12: display

 function display($tpl = null)
 {
     $layout = $this->getLayout();
     if ($layout == 'multisubscription') {
         $this->newsletters = array();
         if (isset($this->mmsg)) {
             jincimport('utility.servicelocator');
             $servicelocator = ServiceLocator::getInstance();
             $logger = $servicelocator->getLogger();
             jincimport('core.newsletterfactory');
             $ninstance = NewsletterFactory::getInstance();
             foreach ($this->mmsg as $news_id => $text) {
                 if ($newsletter = $ninstance->loadNewsletter($news_id, true)) {
                     $this->newsletters[$news_id] = $newsletter;
                 }
             }
         }
     } else {
         $news_id = JRequest::getInt('id', 0);
         jincimport('core.newsletterfactory');
         $ninstance = NewsletterFactory::getInstance();
         if ($newsletter = $ninstance->loadNewsletter($news_id, true)) {
             $this->newsletter = $newsletter;
         }
     }
     parent::display($tpl);
 }
开发者ID:sulicz,项目名称:JINC_J30,代码行数:27,代码来源:view.html.php


示例13: __construct

 public function __construct()
 {
     parent::__construct();
     $userRepository = new UserRepository();
     $this->presenter = new ManageReservationsPresenter($this, new ScheduleAdminManageReservationsService(new ReservationViewRepository(), $userRepository, new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization())), new ScheduleAdminScheduleRepository($userRepository, ServiceLocator::GetServer()->GetUserSession()), new ResourceAdminResourceRepository($userRepository, ServiceLocator::GetServer()->GetUserSession()), new AttributeService(new AttributeRepository()), new UserPreferenceRepository());
     $this->SetPageId('manage-reservations-schedule-admin');
 }
开发者ID:ksdtech,项目名称:booked,代码行数:7,代码来源:ScheduleAdminManageReservationsPage.php


示例14: ProcessPageLoad

 public function ProcessPageLoad()
 {
     $this->presenter->PageLoad();
     $this->Set('priorities', range(1, 10));
     $this->Set('timezone', ServiceLocator::GetServer()->GetUserSession()->Timezone);
     $this->Display('Admin/manage_announcements.tpl');
 }
开发者ID:hugutux,项目名称:booked,代码行数:7,代码来源:ManageAnnouncementsPage.php


示例15: Notify

 /**
  * @param ReservationSeries $reservationSeries
  * @return void
  */
 public function Notify($reservationSeries)
 {
     $resourceAdmins = array();
     $applicationAdmins = array();
     $groupAdmins = array();
     if ($this->SendForResourceAdmins($reservationSeries)) {
         $resourceAdmins = $this->userViewRepo->GetResourceAdmins($reservationSeries->ResourceId());
     }
     if ($this->SendForApplicationAdmins($reservationSeries)) {
         $applicationAdmins = $this->userViewRepo->GetApplicationAdmins();
     }
     if ($this->SendForGroupAdmins($reservationSeries)) {
         $groupAdmins = $this->userViewRepo->GetGroupAdmins($reservationSeries->UserId());
     }
     $admins = array_merge($resourceAdmins, $applicationAdmins, $groupAdmins);
     if (count($admins) == 0) {
         // skip if there is nobody to send to
         return;
     }
     $owner = $this->userRepo->LoadById($reservationSeries->UserId());
     $resource = $reservationSeries->Resource();
     $adminIds = array();
     /** @var $admin UserDto */
     foreach ($admins as $admin) {
         $id = $admin->Id();
         if (array_key_exists($id, $adminIds) || $id == $owner->Id()) {
             // only send to each person once
             continue;
         }
         $adminIds[$id] = true;
         $message = $this->GetMessage($admin, $owner, $reservationSeries, $resource);
         ServiceLocator::GetEmailService()->Send($message);
     }
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:38,代码来源:AdminEmailNotification.php


示例16: ImportFromCSV

 /**
  * The newsletter importer. It imports newsletter subscribers from a CSV file.
  *
  * @access	public
  * @param	integer $newsletter a newsletter object.
  * @param	string  $csvfile_name the CSV file name.
  * @return  array containing import results.
  * @since	0.6
  * @see     Newsletter
  */
 function ImportFromCSV($newsletter, $csvfile_name)
 {
     jincimport('utility.jincjoomlahelper');
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if (!($handle = @fopen($csvfile_name, "r"))) {
         $logger->finer('NewsletterImporter: unable to open ' . $csvfile_name);
         return false;
     }
     $result = array();
     while (($data = fgetcsv($handle, $this->_LINE_MAX_LENGTH, ",")) !== FALSE) {
         $logger->finer('NewsletterImporter: importing ' . implode(', ', $data));
         $info = $newsletter->getSubscriptionInfo();
         $subscriber_info = array();
         $attributes = array();
         for ($i = 0; $i < count($info); $i++) {
             $prefix = substr($info[$i], 0, 5);
             if ($prefix == 'attr_') {
                 $suffix = substr($info[$i], 5);
                 $attributes[$suffix] = isset($data[$i]) ? $data[$i] : '';
             } else {
                 $subscriber_info[$info[$i]] = $data[$i];
             }
         }
         $sub_result = array();
         $sub_result['data'] = implode(', ', $subscriber_info);
         switch ($newsletter->getType()) {
             case NEWSLETTER_PUBLIC_NEWS:
                 $subscriber_info['noptin'] = true;
                 break;
             case NEWSLETTER_PRIVATE_NEWS:
                 $user_id = $subscriber_info['user_id'];
                 $user_info = JINCJoomlaHelper::getUserInfo($user_id);
                 if (empty($user_info)) {
                     $user_info = JINCJoomlaHelper::getUserInfoByUsername($user_id);
                     if (empty($user_info)) {
                         $user_info = JINCJoomlaHelper::getUserInfoByUsermail($user_id);
                         if (!empty($user_info)) {
                             $subscriber_info['user_id'] = $user_info['id'];
                         }
                     } else {
                         $subscriber_info['user_id'] = $user_info['id'];
                     }
                 }
                 break;
             default:
                 break;
         }
         if ($newsletter->subscribe($subscriber_info, $attributes)) {
             $sub_result['result'] = 'OK';
         } else {
             $sub_result['result'] = $newsletter->getError();
         }
         array_push($result, $sub_result);
     }
     fclose($handle);
     return $result;
 }
开发者ID:sulicz,项目名称:JINC_J30,代码行数:69,代码来源:newsletterimporter.php


示例17: Handle

 /**
  * @param ReservationItemView $existingReservation
  * @return bool
  */
 public function Handle(ReservationItemView $existingReservation)
 {
     $reservation = $this->repository->LoadById($existingReservation->GetId());
     $reservation->ApplyChangesTo(SeriesUpdateScope::ThisInstance);
     $reservation->Delete(ServiceLocator::GetServer()->GetUserSession());
     $this->repository->Delete($reservation);
     return true;
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:12,代码来源:ReservationConflictResolution.php


示例18: Create

 public static function Create()
 {
     if (ServiceLocator::GetServer()->GetQuerystring(QueryStringKeys::RESPONSE_TYPE) == 'json') {
         return new ReservationDeleteJsonPage();
     } else {
         return new ReservationDeletePage();
     }
 }
开发者ID:hugutux,项目名称:booked,代码行数:8,代码来源:reservation_delete.php


示例19: __construct

 public function __construct()
 {
     parent::__construct();
     $this->_presenter->SetUserRepository(new GroupAdminUserRepository(new GroupRepository(), ServiceLocator::GetServer()->GetUserSession()));
     $groupRepository = new GroupAdminGroupRepository(new UserRepository(), ServiceLocator::GetServer()->GetUserSession());
     $this->_presenter->SetGroupRepository($groupRepository);
     $this->_presenter->SetGroupViewRepository($groupRepository);
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:8,代码来源:GroupAdminManageUsersPage.php


示例20: PageLoad

 public function PageLoad()
 {
     $this->presenter->PageLoad(ServiceLocator::GetServer()->GetUserSession());
     header("Content-Type: text/Calendar");
     header("Content-Disposition: inline; filename=calendar.ics");
     $display = new CalendarExportDisplay();
     echo $display->Render($this->reservations);
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:8,代码来源:CalendarExportPage.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ServiceUtil类代码示例发布时间:2022-05-23
下一篇:
PHP ServiceFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap