本文整理汇总了PHP中Zend\Session\SessionManager::getValidatorChain方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::getValidatorChain方法的具体用法?PHP SessionManager::getValidatorChain怎么用?PHP SessionManager::getValidatorChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Session\SessionManager
的用法示例。
在下文中一共展示了SessionManager::getValidatorChain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a new user session manager object.
*
* @param ConfigManager $configManager
* @param UserManager $userManager
* @param SessionManager $sessionManager;
*/
public function __construct(ConfigManager $configManager, UserManager $userManager, SessionManager $sessionManager)
{
$this->configManager = $configManager;
$this->userManager = $userManager;
$this->sessionManager = $sessionManager;
/* Prepare session validators */
$sessionManager->getValidatorChain()->attach('session.validate', array(new HttpUserAgent(), 'isValid'));
$sessionManager->getValidatorChain()->attach('session.validate', array(new RemoteAddr(), 'isValid'));
}
示例2: initSession
public function initSession($config, \Zend\ServiceManager\ServiceManager $sm)
{
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions($config);
$sessionManager = new SessionManager($sessionConfig);
$sessionManager->getValidatorChain()->attach('session.validate', array(new HttpUserAgent(), 'isValid'));
$sessionManager->getValidatorChain()->attach('session.validate', array(new RemoteAddr(), 'isValid'));
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$tableGateway = new TableGateway(new TableIdentifier('sessions', 'users'), $dbAdapter);
$saveHandler = new DbTableGateway($tableGateway, new DbTableGatewayOptions());
$sessionManager->setSaveHandler($saveHandler);
$sessionManager->start();
Container::setDefaultManager($sessionManager);
}
示例3: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('JYLibrary\\Model\\SessionTable' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$table = new SessionTable($dbAdapter);
return $table;
}, 'Zend\\Session\\SessionManager' => function ($sm) {
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session'];
$sessionConfig = null;
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : array();
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
$sessionStorage = null;
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
$sessionSaveHandler = null;
if (isset($session['save_handler'])) {
// class should be fetched from service manager since it will require constructor arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
if (isset($session['validator'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validator'] as $validator) {
$validator = new $validator();
$chain->attach('session.validate', array($validator, 'isValid'));
}
}
} else {
$sessionManager = new SessionManager();
/*
$adapter = new \Zend\Db\Adapter\Adapter(array(
'driver' => 'Mysqli',
'database' => 'jymobile',
'username' => 'root',
'password' => '',
'hostname'=>'localhost'
));
$tableGateway = new TableGateway('session', $adapter);
$saveHandler = new DbTableGateway($tableGateway, new DbTableGatewayOptions());
$manager = new SessionManager();
$manager->setSaveHandler($saveHandler);
//echo '×Ô¶¨ÒåsessionManager';
*/
}
Container::setDefaultManager($sessionManager);
return $sessionManager;
}));
}
示例4: getSessionManager
public function getSessionManager()
{
$sessionManager = new ZendSessionManager($this->getConfigObject(), $this->getStorageObject(), $this->getSessionSaveHandler());
$chain = $sessionManager->getValidatorChain();
foreach ($this->getSessionOptions()->getValidators() as $validatorName) {
$validator = $this->validatorPluginManager->get($validatorName);
$chain->attach('session.validate', array($validator, 'isValid'));
}
SessionContainer::setDefaultManager($sessionManager);
return $sessionManager;
}
示例5: getServiceConfig
/**
COPY DARI SIMBRA :D
**/
public function getServiceConfig()
{
return array('factories' => array('Fauth\\Model\\User' => function ($sm) {
$adapter = $sm->get('TNDE\\DbAdapter');
$table = new UserDbTable($adapter);
return $table;
}, 'Zend\\Session\\SessionManager' => function ($sm) {
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session'];
$sessionConfig = null;
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : array();
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
$sessionStorage = null;
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
$sessionSaveHandler = null;
if (isset($session['save_handler'])) {
// class should be fetched from service manager since it will require constructor arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
if (isset($session['validator'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validator'] as $validator) {
$validator = new $validator();
$chain->attach('session.validate', array($validator, 'isValid'));
}
}
} else {
$sessionManager = new SessionManager();
}
Container::setDefaultManager($sessionManager);
return $sessionManager;
}, 'Fauth\\sessionContainer' => function ($sm) {
$container = new Container('container');
if (!isset($container->init)) {
$session = $sm->get('Zend\\Session\\SessionManager');
$session->regenerateId(true);
$container->init = 1;
}
return $container;
}, 'Fauth\\authService' => function ($sm) {
$container = $sm->get('Fauth\\sessionContainer');
$authService = new AuthService($container);
return $authService;
}));
}
示例6: register
/**
* Registers services on the given app.
*
* This method should only be used to configure services and parameters.
* It should not get services.
*
* @param Application $app
*/
public function register(Application $app)
{
$app['zend.session.handler._factory'] = $app->protect(function ($type, $options) use($app) {
switch ($type) {
case 'SilexCMF\\ZendSession\\SaveHandler\\Db':
return new Db($app[$options['connection']], new DbOptions());
case 'Zend\\Session\\SaveHandler\\MongoDB':
return new MongoDB($app['mongo'], new MongoDBOptions($options));
}
return null;
});
$app['zend.session.manager'] = $app->share(function () use($app) {
$options = isset($app['zend.session.options']) ? $app['zend.session.options'] : [];
$config = null;
if (isset($options['config'])) {
$config = new SessionConfig();
$config->setOptions($options['config']);
}
$storage = null;
if (isset($options['storage'])) {
$storage = Factory::factory($options['storage']['type'], isset($options['storage']['options']) ? $options['storage']['options'] : []);
}
$handler = null;
if (isset($options['handler'])) {
$handler = $app['zend.session.handler._factory']($options['handler']['type'], isset($options['handler']['options']) ? $options['handler']['options'] : []);
}
$manager = new SessionManager($config, $storage, $handler);
if (isset($options['validators'])) {
/* @var $request \Symfony\Component\HttpFoundation\Request */
$request = $app['request_stack']->getCurrentRequest();
foreach ($options['validators'] as $validator) {
switch ($validator) {
case 'Zend\\Session\\Validator\\HttpUserAgent':
$validator = new $validator($request->server->get('HTTP_USER_AGENT'));
break;
case 'Zend\\Session\\Validator\\RemoteAddr':
$validator = new $validator($request->server->get('REMOTE_ADDR'));
break;
default:
$validator = new $validator();
}
$manager->getValidatorChain()->attach('session.validate', array($validator, 'isValid'));
}
}
Container::setDefaultManager($manager);
return $manager;
});
}
示例7: createService
public function createService(ServiceLocatorInterface $sm)
{
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session'];
$sessionConfig = null;
//если есть ключ, проверить базовые настройки
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : array();
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
//настройка типа хранилища
$sessionStorage = null;
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
//не настроено
$sessionSaveHandler = null;
if (isset($session['save_handler'])) {
// class should be fetched from service manager since
// it will require constructor arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
//применить валидаторы
if (isset($session['validators'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validators'] as $validator) {
$validator = new $validator();
$chain->attach('session.validate', array($validator, 'isValid'));
}
}
} else {
//если нет конфига - возвращаем по умолчанию
// $sessionManager = new SessionManager();
$sessionManager = parent::createService($services);
}
//установка для контейнеров
Container::setDefaultManager($sessionManager);
return $sessionManager;
}
示例8: createService
public function createService(ServiceLocatorInterface $sm)
{
$config = $sm->get('config');
$sessionManager = null;
if (isset($config['uthando_session_manager'])) {
$session = $config['uthando_session_manager'];
$sessionConfig = null;
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : [];
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
$sessionStorage = null;
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
$sessionSaveHandler = null;
if (isset($session['save_handler'])) {
// class should be fetched from service manager since it will require constructor arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
if (isset($session['validators'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validators'] as $validator) {
$validator = new $validator();
$chain->attach('session.validate', [$validator, 'isValid']);
}
}
}
if (null === $sessionManager) {
$sessionManager = new SessionManager();
}
Container::setDefaultManager($sessionManager);
return $sessionManager;
}
示例9: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('Zend\\Session\\SessionManager' => function ($sm) {
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session'];
$sessionConfig = null;
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : array();
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
$sessionStorage = null;
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
$sessionSaveHandler = null;
if (isset($session['save_handler'])) {
// class should be fetched from service manager since it will require constructor arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
if (isset($session['validator'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validator'] as $validator) {
$validator = new $validator();
$chain->attach('session.validate', array($validator, 'isValid'));
}
}
} else {
$sessionManager = new SessionManager();
}
Container::setDefaultManager($sessionManager);
return $sessionManager;
}));
}
示例10: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('UserTable' => function ($sm) {
$adapter = $sm->get('zend_db_adapter');
$table = new UserTable($adapter);
return $table;
}, 'ProvTable' => function ($sm) {
$adapter = $sm->get('zend_db_adapter');
$table = new ProvTable($adapter);
return $table;
}, 'AuthTable' => function ($sm) {
$adapter = $sm->get('zend_db_adapter');
$table = new AuthTable($adapter);
return $table;
}, 'UserCredential' => function ($sm) {
$adapter = $sm->get('zend_db_adapter');
$table = new CredentialTable($adapter);
return $table;
}, 'Zend\\Session\\SessionManager' => function ($sm) {
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session'];
$sessionConfig = null;
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : array();
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
$sessionStorage = null;
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
$sessionSaveHandler = null;
if (isset($session['save_handler'])) {
// class should be fetched from service
// manager since it will require constructor
// arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
if (isset($session['validators'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validators'] as $validator) {
foreach ($validator as $validatorCurrent) {
$validator = new $validatorCurrent();
$chain->attach('session.validate', array($validator, 'isValid'));
}
}
}
} else {
$sessionManager = new SessionManager();
}
Container::setDefaultManager($sessionManager);
return $sessionManager;
}, 'mail.transport' => function ($sm) {
$config = $sm->get('Config');
$transport = new Smtp();
$transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
return $transport;
}, 'mail.transport2' => function ($sm) {
$config = $sm->get('Config');
$transport = new Smtp();
$transport->setOptions(new SmtpOptions($config['mail2']['transport']['options']));
return $transport;
}, 'auth_service' => function ($sm) {
$auth = new AuthenticationService();
return $auth;
}));
}
示例11: getServiceConfig
public function getServiceConfig()
{
return array('invokables' => array('service_universal_dashboard_main' => 'DDD\\Service\\UniversalDashboard\\Main', 'service_accommodations' => 'DDD\\Service\\Accommodations', 'service_upload' => 'DDD\\Service\\Upload', 'service_partners' => 'DDD\\Service\\Partners', 'service_partner_gcm_value' => 'DDD\\Service\\PartnerGcmValue', 'service_currency_currency' => 'DDD\\Service\\Currency\\Currency', 'service_currency_currency_vault' => 'DDD\\Service\\Currency\\CurrencyVault', 'service_profile' => 'DDD\\Service\\Profile', 'service_location' => 'DDD\\Service\\Location', 'service_review' => 'DDD\\Service\\Review', 'service_booking' => 'DDD\\Service\\Booking', 'service_blog' => 'DDD\\Service\\Blog', 'service_news' => 'DDD\\Service\\News', 'service_language' => 'DDD\\Service\\Language', 'service_translation' => 'DDD\\Service\\Translation', 'service_textline' => 'DDD\\Service\\Textline', 'service_channel_manager' => 'DDD\\Service\\ChannelManager', 'service_queue_inventory_synchronization_queue' => 'DDD\\Service\\Queue\\InventorySynchronizationQueue', 'service_distribution' => 'DDD\\Service\\Distribution', 'service_queue_email_queue' => 'DDD\\Service\\Queue\\EmailQueue', 'service_apartment_group' => 'DDD\\Service\\ApartmentGroup', 'service_apartment_group_main' => 'DDD\\Service\\ApartmentGroup\\Main', 'service_apartment_group_deactivate' => 'DDD\\Service\\ApartmentGroup\\Deactivate', 'service_apartment_group_usages_concierge' => 'DDD\\Service\\ApartmentGroup\\Usages\\Concierge', 'service_apartment_group_usages_apartel' => 'DDD\\Service\\ApartmentGroup\\Usages\\Apartel', 'service_apartment_group_usages_building' => 'DDD\\Service\\ApartmentGroup\\Usages\\Building', 'service_user' => 'DDD\\Service\\User', 'service_user_main' => 'DDD\\Service\\User\\Main', 'service_user_documents' => 'DDD\\Service\\User\\Documents', 'service_user_evaluations' => 'DDD\\Service\\User\\Evaluations', 'service_user_schedule' => 'DDD\\Service\\User\\Schedule', 'service_user_disable_user' => 'DDD\\Service\\User\\DisableUser', 'service_user_permissions' => 'DDD\\Service\\User\\Permissions', 'service_user_vacation' => 'DDD\\Service\\User\\Vacation', 'service_user_external_account' => 'DDD\\Service\\User\\ExternalAccount', 'service_user_salary_scheme' => 'DDD\\Service\\User\\SalaryScheme', 'service_apartment_amenities' => 'DDD\\Service\\Apartment\\Amenities', 'service_apartment_amenity_items' => 'DDD\\Service\\Apartment\\AmenityItems', 'service_apartment_main' => 'DDD\\Service\\Apartment\\Main', 'service_apartment_general' => 'DDD\\Service\\Apartment\\General', 'service_apartment_details' => 'DDD\\Service\\Apartment\\Details', 'service_apartment_location' => 'DDD\\Service\\Apartment\\Location', 'service_apartment_rate' => 'DDD\\Service\\Apartment\\Rate', 'service_apartment_inventory' => 'DDD\\Service\\Apartment\\Inventory', 'service_apartment_review' => 'DDD\\Service\\Apartment\\Review', 'service_apartment_furniture' => 'DDD\\Service\\Apartment\\Furniture', 'service_apartment_statistics' => 'DDD\\Service\\Apartment\\Statistics', 'service_apartment_logs' => 'DDD\\Service\\Apartment\\Logs', 'service_parking_general' => 'DDD\\Service\\Parking\\General', 'service_parking_inventory' => 'DDD\\Service\\Parking\\Inventory', 'service_parking_spot' => 'DDD\\Service\\Parking\\Spot', 'service_parking_spot_inventory' => 'DDD\\Service\\Parking\\Spot\\Inventory', 'service_apartment_group_facilities' => 'DDD\\Service\\ApartmentGroup\\Facilities', 'service_apartment_group_facility_items' => 'DDD\\Service\\ApartmentGroup\\FacilityItems', 'service_apartment_group_building_details' => 'DDD\\Service\\ApartmentGroup\\BuildingDetails', 'service_penalty_calculation' => 'DDD\\Service\\PenaltyCalculation', 'service_task' => 'DDD\\Service\\Task', 'service_group_inventory' => 'DDD\\Service\\GroupInventory', 'service_geolite_country' => 'DDD\\Service\\GeoliteCountry', 'service_booking_management' => 'DDD\\Service\\Booking\\BookingManagement', 'service_booking_booking_ticket' => 'DDD\\Service\\Booking\\BookingTicket', 'service_booking_charge' => 'DDD\\Service\\Booking\\Charge', 'service_booking_bank_transaction' => 'DDD\\Service\\Booking\\BankTransaction', 'service_booking_booking_addon' => 'DDD\\Service\\Booking\\BookingAddon', 'service_booking_reservation_issues' => 'DDD\\Service\\Booking\\ReservationIssues', 'service_booking_attachment' => 'DDD\\Service\\Booking\\Attachment', 'service_money_account' => 'DDD\\Service\\MoneyAccount', 'service_money_account_attachment' => 'DDD\\Service\\MoneyAccountAttachment', 'service_psp' => 'DDD\\Service\\Psp', 'service_universal_dashboard_widget_ki_not_viewed' => 'DDD\\Service\\UniversalDashboard\\Widget\\KINotViewed', 'service_universal_dashboard_widget_no_collection' => 'DDD\\Service\\UniversalDashboard\\Widget\\NoCollection', 'service_universal_dashboard_widget_collect_from_customer' => 'DDD\\Service\\UniversalDashboard\\Widget\\CollectFromCustomer', 'service_universal_dashboard_widget_pay_to_customer' => 'DDD\\Service\\UniversalDashboard\\Widget\\PayToCustomer', 'service_universal_dashboard_widget_to_be_settled' => 'DDD\\Service\\UniversalDashboard\\Widget\\ToBeSettled', 'service_universal_dashboard_widget_pending_transaction' => 'DDD\\Service\\UniversalDashboard\\Widget\\PendingTransaction', 'service_universal_dashboard_widget_collect_from_partner' => 'DDD\\Service\\UniversalDashboard\\Widget\\CollectFromPartner', 'service_universal_dashboard_widget_validate_cc' => 'DDD\\Service\\UniversalDashboard\\Widget\\ValidateCC', 'service_universal_dashboard_widget_pending_cancellation' => 'DDD\\Service\\UniversalDashboard\\Widget\\PendingCancelation', 'service_universal_dashboard_widget_in_registration_process' => 'DDD\\Service\\UniversalDashboard\\Widget\\InRegistrationProcess', 'service_universal_dashboard_widget_suspended_apartments' => 'DDD\\Service\\UniversalDashboard\\Widget\\SuspendedApartments', 'service_universal_dashboard_widget_pinned_reservation' => 'DDD\\Service\\UniversalDashboard\\Widget\\PinnedReservation', 'service_universal_dashboard_widget_resolve_comments' => 'DDD\\Service\\UniversalDashboard\\Widget\\ResolveComments', 'service_universal_dashboard_widget_not_charged_apartel_reservations' => 'DDD\\Service\\UniversalDashboard\\Widget\\NotChargedApartelReservations', 'service_universal_dashboard_widget_overbooking_reservations' => 'DDD\\Service\\UniversalDashboard\\Widget\\OverbookingReservations', 'service_universal_dashboard_widget_upcoming_evaluations' => 'DDD\\Service\\UniversalDashboard\\Widget\\UpcomingEvaluations', 'service_universal_dashboard_widget_evaluation_less_employees' => 'DDD\\Service\\UniversalDashboard\\Widget\\EvaluationLessEmployees', 'service_universal_dashboard_widget_time_off_requests' => 'DDD\\Service\\UniversalDashboard\\Widget\\TimeOffRequests', 'service_ota_distribution' => 'DDD\\Service\\OTADistribution', 'service_website_cache' => 'DDD\\Service\\Website\\Cache', 'service_apartment_ota_distribution' => 'DDD\\Service\\Apartment\\OTADistribution', 'service_notifications' => 'DDD\\Service\\Notifications', 'service_apartment_review_category' => 'DDD\\Service\\Apartment\\ReviewCategory', 'service_taxes' => 'DDD\\Service\\Taxes', 'service_team_team' => 'DDD\\Service\\Team\\Team', 'service_office' => 'DDD\\Service\\Office', 'service_finance_customer' => 'DDD\\Service\\Finance\\Customer', 'service_finance_account_receivable_chart' => 'DDD\\Service\\Finance\\AccountReceivable\\Chart', 'service_common' => 'DDD\\Service\\Common', 'service_fraud' => 'DDD\\Service\\Fraud', 'service_recruitment_applicant' => 'DDD\\Service\\Recruitment\\Applicant', 'service_reservation_main' => 'DDD\\Service\\Reservation\\Main', 'service_reservation_worst_cxl_policy_selector' => 'DDD\\Service\\Reservation\\WorstCXLPolicySelector', 'service_reservation_partner_specific' => 'DDD\\Service\\Reservation\\PartnerSpecific', 'service_availability' => 'DDD\\Service\\Availability', 'service_email_sender' => 'DDD\\Service\\EmailSender', 'service_frontier' => 'DDD\\Service\\Frontier', 'service_finance_transaction_account' => 'DDD\\Service\\Finance\\TransactionAccount', 'service_team_usages_base' => 'DDD\\Service\\Team\\Usages\\Base', 'service_team_usages_security' => 'DDD\\Service\\Team\\Usages\\Security', 'service_team_usages_frontier' => 'DDD\\Service\\Team\\Usages\\Frontier', 'service_team_usages_hiring' => 'DDD\\Service\\Team\\Usages\\Hiring', 'service_team_usages_procurement' => 'DDD\\Service\\Team\\Usages\\Procurement', 'service_customer' => 'DDD\\Service\\Customer', 'service_reservation_rate_selector' => 'DDD\\Service\\Reservation\\RateSelector', 'service_lock_general' => 'DDD\\Service\\Lock\\General', 'service_lock_usages_apartment' => 'DDD\\Service\\Lock\\Usages\\Apartment', 'service_lock_usages_building' => 'DDD\\Service\\Lock\\Usages\\Building', 'service_lock_usages_parking' => 'DDD\\Service\\Lock\\Usages\\Parking', 'service_reservation_charge_authorization' => 'DDD\\Service\\Reservation\\ChargeAuthorization', 'service_cubilis_connection' => 'DDD\\Service\\Cubilis\\Connection', 'service_reservation_identificator' => 'DDD\\Service\\Reservation\\Identificator', 'service_tag_tag' => 'DDD\\Service\\Tag\\Tag', 'service_warehouse_category' => 'DDD\\Service\\Warehouse\\Category', 'service_warehouse_storage' => 'DDD\\Service\\Warehouse\\Storage', 'service_finance_budget' => 'DDD\\Service\\Finance\\Budget', 'service_warehouse_asset' => 'DDD\\Service\\Warehouse\\Asset', 'service_document_document' => 'DDD\\Service\\Document\\Document', 'service_unit_testing' => 'DDD\\Service\\UnitTesting', 'service_cache_memcache' => 'DDD\\Service\\Cache\\Memcache', 'library_service_google_auth' => 'Library\\Service\\GoogleAuth', 'service_website_search' => 'DDD\\Service\\Website\\Search', 'service_website_apartment' => 'DDD\\Service\\Website\\Apartment'), 'factories' => array('Zend\\Session\\SessionManager' => function ($sm) {
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session'];
$sessionSaveHandler = null;
$sessionStorage = null;
$sessionConfig = null;
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : [];
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
if (isset($session['save_handler'])) {
// class should be fetched from service manager since it will require constructor arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
if (isset($session['validator'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validator'] as $validator) {
$validator = new $validator();
$chain->attach('session.validate', [$validator, 'isValid']);
}
}
} else {
$sessionManager = new SessionManager();
}
Container::setDefaultManager($sessionManager);
return $sessionManager;
}, 'Library\\Authentication\\BackofficeAuthenticationService' => function ($sm) {
$authAdapter = new BcryptDbAdapter($sm->get('dbadapter'), DbTables::TBL_BACKOFFICE_USERS, 'email', 'password');
$authStorage = new AuthStorage();
$backofficeAuthenticationService = new BackofficeAuthenticationService($authStorage, $authAdapter);
$backofficeAuthenticationService->setServiceManager($sm);
return $backofficeAuthenticationService;
}, 'MainNavigation' => function ($sm) {
$authUser = $sm->get('library_backoffice_auth');
if (!$authUser->hasIdentity()) {
$url = $sm->get('router')->assemble([], ['name' => 'backoffice_user_login']);
$response = $sm->get('response');
$response->getHeaders()->addHeaderLine('Location', $url);
$response->setStatusCode(302);
$response->sendHeaders();
return $response;
}
$navigation = new BackofficeNavigation();
$navigation->setName('main');
return $navigation->createService($sm);
}, 'ProfileNavigation' => function ($sm) {
$navigation = new BackofficeNavigation();
$navigation->setName('profile');
return $navigation->createService($sm);
}, 'NotificationsNavigation' => function ($sm) {
$navigation = new BackofficeNavigation();
$navigation->setName('notifications');
return $navigation->createService($sm);
}, 'ChannelManager' => function ($sm) {
return new ChannelManager($sm);
}, 'ActionLogger' => function ($sm) {
return new \Library\ActionLogger\Logger($sm);
}, 'CurrencyList' => function ($sm) {
return $sm->get('dao_currency_currency')->getAllCurrencies();
}, 'DDD\\Service\\Location' => function ($sm) {
$as = new \DDD\Service\Location();
$as->setServiceLocator($sm);
return $as;
}, 'DDD\\Service\\Website\\Cache' => function ($sm) {
$service = new \DDD\Service\Website\Cache();
$service->setServiceLocator($sm);
return $service;
}, 'DDD\\Service\\Notifications' => function ($sm) {
$service = new \DDD\Service\Notifications();
$service->setServiceLocator($sm);
return $service;
}, 'DDD\\Dao\\User\\Users' => function ($sm) {
$as = new \DDD\Dao\User\Users($sm);
return $as;
}, 'DDD\\Dao\\User\\UserManager' => function ($sm) {
$as = new \DDD\Dao\User\UserManager($sm);
return $as;
}, 'DDD\\Dao\\User\\UserGroup' => function ($sm) {
$as = new \DDD\Dao\User\UserGroup($sm);
return $as;
}, 'DDD\\Dao\\User\\Schedule\\Schedule' => function ($sm) {
$as = new \DDD\Dao\User\Schedule\Schedule($sm);
return $as;
}, 'DDD\\Dao\\User\\Schedule\\Inventory' => function ($sm) {
$as = new \DDD\Dao\User\Schedule\Inventory($sm);
return $as;
}, 'DDD\\Dao\\User\\Document\\Documents' => function ($sm) {
$as = new \DDD\Dao\User\Document\Documents($sm);
return $as;
}, 'DDD\\Dao\\User\\Document\\DocumentTypes' => function ($sm) {
//.........这里部分代码省略.........
示例12: _init
public function _init(Dispatcher $dispatcher)
{
// 引入Composer,Yaf扩展的配置项yaf.use_spl_autoload务必设置为1
if (file_exists(ROOT_PATH . '/vendor/autoload.php')) {
$loader = (include ROOT_PATH . '/vendor/autoload.php');
//$loader->add("",ROOT_PATH.'/library');
//$loader->addPsr4("Zend\\",ROOT_PATH.'/library/Zend');
Registry::set('loader', $loader);
}
// 禁止自动渲染
$dispatcher->autoRender(FALSE);
// 保存配置
$this->_config = Application::app()->getConfig();
Registry::set('config', $this->_config);
// 报错设置
if ($this->_config->global->showError) {
error_reporting(-1);
ini_set('display_errors', 'On');
}
// 加解密
if (!empty($this->_config->global->key)) {
Registry::set('enc', function () {
$blockCipher = BlockCipher::factory('mcrypt', array('algo' => 'aes'));
$blockCipher->setKey($this->_config->global->key);
return $blockCipher;
});
}
// 命令行方式,跳过SESSION
if (!defined("RUN_IN_CLI")) {
// 保存路径
$sessionConfig = $this->_config->session->toArray();
if (isset($sessionConfig['save_path'])) {
@mkdir($sessionConfig['save_path'], 0777, true);
}
// 配置
$config = new SessionConfig();
$config->setOptions($sessionConfig);
// 会话管理器
$manager = new SessionManager($config);
// 开启会话
$manager->start();
// 验证会话
$manager->getValidatorChain()->attach('session.validate', array(new HttpUserAgent(), 'isValid'));
if (!$manager->isValid()) {
$manager->destroy();
throw new \Exception("会话验证失败");
}
// 会话Token
$default = new Zend\Session\Container();
if (empty($default->offsetGet('securityToken'))) {
$default->offsetSet('securityToken', md5(uniqid(rand(), true)));
}
// 保存实例
Registry::set('session', $default);
Registry::set('sm', $manager);
}
// 数据库
Registry::set('db', function () {
$mysqlMasterConfig = $this->_config->mysql->master->toArray();
$adapter = new Adapter($mysqlMasterConfig);
$connect = $adapter->getDriver()->getConnection();
for ($i = 0; $i < 5; $i++) {
if ($connect->isConnected()) {
break;
}
$connect->connect();
}
return $adapter;
});
// 邮件
Registry::set('mail', function () {
$options = new SmtpOptions($this->_config->smtp->toArray());
$mail = new SmtpTransport();
$mail->setOptions($options);
return $mail;
});
// 日志
Registry::set('logger', function () {
$logger = new Zend\Log\Logger();
$writer = new Zend\Log\Writer\Stream($this->_config->log->path . '/' . date("Ymd") . ".log");
$logger->addWriter($writer);
return $logger;
});
}
示例13: getServiceConfig
/**
* Expected to return \Zend\ServiceManager\Config object or array to
* seed such an object.
*
* @return array|\Zend\ServiceManager\Config
*/
public function getServiceConfig()
{
return ['initializers' => ['EntityManager' => function ($instance, ServiceManager $sm) {
if ($instance instanceof EntityManagerAwareInterface) {
/** @var EntityManager $entityManager */
$entityManager = $sm->get('Doctrine\\ORM\\EntityManager');
$instance->setEntityManager($entityManager);
}
}], 'factories' => ['Zend\\Authentication\\AuthenticationService' => function ($serviceManager) {
return $serviceManager->get('doctrine.authenticationservice.orm_default');
}, 'Zend\\Session\\SessionManager' => function ($sm) {
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session'];
$sessionConfig = null;
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : array();
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
$sessionStorage = null;
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
$sessionSaveHandler = null;
if (isset($session['save_handler'])) {
// class should be fetched from service manager since it will require constructor arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
if (isset($session['validator'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validator'] as $validator) {
$validator = new $validator();
$chain->attach('session.validate', array($validator, 'isValid'));
}
}
} else {
$sessionManager = new SessionManager();
}
Container::setDefaultManager($sessionManager);
return $sessionManager;
}, 'UserService' => function (ServiceManager $sm) {
return new UserService($sm->get('Zend\\Authentication\\AuthenticationService'), $sm->get('Zend\\Session\\SessionManager'));
}]];
}
示例14: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('Application\\Model\\Common' => function ($sm) {
$model = new \Application\Model\Common();
$model->setServiceLocator($sm);
return $model;
}, 'Application\\Model\\MyAuthStorage' => function ($sm) {
return new \Application\Model\MyAuthStorage('zf_tutorial');
}, 'AuthService' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'users', 'user_name', 'pass', 'MD5(?)');
$authService = new AuthenticationService();
$authService->setAdapter($dbTableAuthAdapter);
$authService->setStorage($sm->get('Application\\Model\\MyAuthStorage'));
return $authService;
}, 'Zend\\Session\\SessionManager' => function ($sm) {
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session'];
$sessionConfig = null;
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : array();
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
$sessionStorage = null;
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
$sessionSaveHandler = null;
if (isset($session['save_handler'])) {
// class should be fetched from service manager since it will require constructor arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
if (isset($session['validator'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validator'] as $validator) {
$validator = new $validator();
$chain->attach('session.validate', array($validator, 'isValid'));
}
}
} else {
$sessionManager = new SessionManager();
}
Container::setDefaultManager($sessionManager);
return $sessionManager;
}));
}
示例15: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('Tee\\Options\\Configuration' => function ($sm) {
$config = $sm->get('Config');
return new \Tee\Options\Configuration($config['cfg']);
}, 'Tee\\Entity\\PoxnTable' => function ($sm) {
return new \Tee\Entity\PoxnTable($sm->get('Zend\\Db\\Adapter\\Adapter'));
}, 'Tee\\Entity\\PersonRespTable' => function ($sm) {
return new \Tee\Entity\PersonRespTable($sm->get('Zend\\Db\\Adapter\\Adapter'));
}, 'Tee\\Entity\\PersonPoxnTable' => function ($sm) {
return new \Tee\Entity\PersonPoxnTable($sm->get('Zend\\Db\\Adapter\\Adapter'));
}, 'TeeCache' => function ($sm) {
$config = $sm->get('Config');
return \Zend\Cache\StorageFactory::factory($config['cache']);
}, 'TeeMail' => function ($sm) {
$config = $sm->get('Config');
$smptOptions = new SmtpOptions($config['transport']['smtp_options']);
return new SmtpTransport($smptOptions);
}, 'TeeSessionManager' => function ($sm) {
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session'];
$sessionConfig = null;
if (isset($session['config'])) {
$class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
$options = isset($session['config']['options']) ? $session['config']['options'] : array();
$sessionConfig = new $class();
$sessionConfig->setOptions($options);
}
$sessionStorage = null;
if (isset($session['storage'])) {
$class = $session['storage'];
$sessionStorage = new $class();
}
$sessionSaveHandler = null;
if (isset($session['save_handler'])) {
// class should be fetched from service manager since it will require constructor arguments
$sessionSaveHandler = $sm->get($session['save_handler']);
}
$sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
if (isset($session['validators'])) {
$chain = $sessionManager->getValidatorChain();
foreach ($session['validators'] as $validator) {
$validator = new $validator();
$chain->attach('session.validate', array($validator, 'isValid'));
}
}
} else {
$sessionManager = new SessionManager();
}
Container::setDefaultManager($sessionManager);
return $sessionManager;
}, 'LovService' => function ($sm) {
return new \Tee\Entity\LovTable($sm->get('Zend\\Db\\Adapter\\Adapter'), $sm->get('TeeCache'));
}, 'LocaleService' => function ($sm) {
return new \Tee\Entity\LocaleTable($sm->get('Zend\\Db\\Adapter\\Adapter'), $sm->get('TeeCache'));
}, 'LanguageService' => function ($sm) {
return new \Tee\Entity\LanguageTable($sm->get('Zend\\Db\\Adapter\\Adapter'), $sm->get('TeeCache'));
}, 'TimezoneService' => function ($sm) {
return new \Tee\Entity\TimezoneTable($sm->get('Zend\\Db\\Adapter\\Adapter'), $sm->get('TeeCache'));
}, 'CountryService' => function ($sm) {
return new \Tee\Entity\CountryTable($sm->get('Zend\\Db\\Adapter\\Adapter'), $sm->get('TeeCache'));
}, 'StateService' => function ($sm) {
return new \Tee\Entity\StateTable($sm->get('Zend\\Db\\Adapter\\Adapter'), $sm->get('TeeCache'));
}, 'CommtypeService' => function ($sm) {
return new \Tee\Entity\CommtypeTable($sm->get('Zend\\Db\\Adapter\\Adapter'), $sm->get('TeeCache'));
}));
}