Skip to content
Snippets Groups Projects
Commit aa634a22 authored by Frank Morgner's avatar Frank Morgner
Browse files

Merge branch 'master' of 172.18.85.101:vufind2

parents f3726b9b db646ca6
No related merge requests found
...@@ -9,7 +9,9 @@ $config = [ ...@@ -9,7 +9,9 @@ $config = [
'VuFind\BranchesReader' => 'finc\Service\Factory::getBranchesReader', 'VuFind\BranchesReader' => 'finc\Service\Factory::getBranchesReader',
'VuFind\ILSConnection' => 'finc\Service\Factory::getILSConnection', 'VuFind\ILSConnection' => 'finc\Service\Factory::getILSConnection',
'VuFind\ILSHoldLogic' => 'finc\Service\Factory::getILSHoldLogic', 'VuFind\ILSHoldLogic' => 'finc\Service\Factory::getILSHoldLogic',
'finc\Rewrite' => 'finc\Rewrite\Factory' 'finc\Rewrite' => 'finc\Rewrite\Factory',
'VuFind\SessionManager' => 'finc\Session\ManagerFactory',
'VuFind\CookieManager' => 'finc\Service\Factory::getCookieManager'
] ]
], ],
'controllers' => [ 'controllers' => [
......
<?php
/**
* Cookie Manager
*
* PHP version 5
*
* Copyright (C) Villanova University 2015.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind
* @package Cookie
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
namespace finc\Cookie;
/**
* Cookie Manager
*
* @category VuFind
* @package Cookie
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class CookieManager extends \VuFind\Cookie\CookieManager
{
/**
* The name of the session cookie
*
* @var string
*/
protected $sessionName;
/**
* Constructor
*
* @param array $cookies Cookie array to manipulate (e.g. $_COOKIE)
* @param string $path Cookie base path (default = /)
* @param string $domain Cookie domain
* @param bool $secure Are cookies secure only? (default = false)
* @param string $sessionName Session cookie name (if null defaults to PHP
* settings)
*/
public function __construct($cookies, $path = '/', $domain = null,
$secure = false, $sessionName = null
) {
$this->cookies = $cookies;
$this->path = $path;
$this->domain = $domain;
$this->secure = $secure;
$this->sessionName = $sessionName;
}
/**
* Get the name of the cookie
*
* @return mixed
*/
public function getSessionName()
{
return $this->sessionName;
}
}
...@@ -69,7 +69,7 @@ class Factory ...@@ -69,7 +69,7 @@ class Factory
$sm->get('VuFind\CacheManager') $sm->get('VuFind\CacheManager')
); );
} }
/** /**
* Construct the ILS connection. * Construct the ILS connection.
* *
...@@ -101,4 +101,37 @@ class Factory ...@@ -101,4 +101,37 @@ class Factory
$sm->get('VuFind\HMAC'), $sm->get('VuFind\Config')->get('config') $sm->get('VuFind\HMAC'), $sm->get('VuFind\Config')->get('config')
); );
} }
/**
* Construct the cookie manager.
*
* @param ServiceManager $sm Service manager.
*
* @return \VuFind\Cookie\CookieManager
*/
public static function getCookieManager(ServiceManager $sm)
{
$config = $sm->get('VuFind\Config')->get('config');
$path = '/';
if (isset($config->Cookies->limit_by_path)
&& $config->Cookies->limit_by_path
) {
$path = $sm->get('Request')->getBasePath();
if (empty($path)) {
$path = '/';
}
}
$secure = isset($config->Cookies->only_secure)
? $config->Cookies->only_secure
: false;
$domain = isset($config->Cookies->domain)
? $config->Cookies->domain
: null;
$session_name = isset($config->Cookies->session_name)
? $config->Cookies->session_name
: null;
return new \finc\Cookie\CookieManager(
$_COOKIE, $path, $domain, $secure, $session_name
);
}
} }
<?php
/**
* Factory for instantiating Session Manager
*
* PHP version 5
*
* Copyright (C) Villanova University 2016.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind
* @package Session_Handlers
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
namespace finc\Session;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Factory for instantiating Session Manager
*
* @category VuFind
* @package Session_Handlers
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*
* @codeCoverageIgnore
*/
class ManagerFactory extends \VuFind\Session\ManagerFactory
{
/**
* Build the options array.
*
* @param ServiceLocatorInterface $sm Service manager
*
* @return array
*/
protected function getOptions(ServiceLocatorInterface $sm)
{
$cookieManager = $sm->get('VuFind\CookieManager');
$options = [
'cookie_path' => $cookieManager->getPath(),
'cookie_secure' => $cookieManager->isSecure()
];
$domain = $cookieManager->getDomain();
if (!empty($domain)) {
$options['cookie_domain'] = $domain;
}
$name = $cookieManager->getSessionName();
if (!empty($name)) {
$options['name'] = $name;
}
return $options;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment