Example #1
0
 /**
  * Sets the response as not modified.
  *
  * @return $this
  */
 public function setAsNotModified()
 {
     $this->setStatusCode(304);
     $this->setContent('');
     // remove headers that MUST NOT be included with 304 Not Modified responses
     $headersToRemove = ['Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified'];
     foreach ($headersToRemove as $header) {
         $this->headers->removeKey($header);
     }
     return $this;
 }
Example #2
0
 /**
  * Register service using given config
  *
  * @param string       $serviceName
  * @param ConfigObject $config
  *
  * @param bool         $overwrite Overwrite service if it has been registered before (Default: false)
  *
  * @throws ServiceManagerException
  * @return $this
  */
 public function registerService($serviceName, ConfigObject $config, $overwrite = false)
 {
     /**
      * Check if service instance already exists
      */
     if ($this->registeredServices->keyExists($serviceName) && !$overwrite) {
         throw new ServiceManagerException(ServiceManagerException::SERVICE_NAME_ALREADY_EXISTS, [$serviceName]);
     }
     $this->registeredServices[$serviceName] = $config;
     if ($this->instantiatedServices->keyExists($serviceName) && $overwrite) {
         $this->instantiatedServices->removeKey($serviceName);
     }
     /**
      * Tagify service
      */
     foreach ($config->get('Tags', []) as $tag) {
         $tagServices = $this->taggedServices->key($tag, [], true);
         $tagServices[] = $serviceName;
         $this->taggedServices->key($tag, $tagServices);
     }
     return $this;
 }
Example #3
0
 /**
  * Removes the route under the given name.
  *
  * @param string $name Route name.
  *
  * @return $this
  */
 public function remove($name)
 {
     return $this->routes->removeKey($name);
 }
Example #4
0
 /**
  * Override __unset
  *
  * @param  string $name
  *
  * @return void
  */
 public function __unset($name)
 {
     if ($this->data->keyExists($name)) {
         $this->data->removeKey($name);
     }
 }
Example #5
0
 /**
  * Removes the given $key from session.
  *
  * @param string $key Name of the session key you wish to remove.
  *
  * @return bool
  */
 public function delete($key)
 {
     $this->sessionBag->removeKey($key);
     unset($_SESSION[$key]);
     return true;
 }
Example #6
0
 public function testRemoveKeys()
 {
     $array = ['k1' => 'val', 'k2' => null, 'k3' => false];
     $a = new ArrayObject($array);
     $a->removeKey(['k2', 'k3']);
     unset($array['k2']);
     unset($array['k3']);
     $this->assertSame($array, $a->val());
 }
Example #7
0
 /**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Offset to unset
  * @link http://php.net/manual/en/arrayaccess.offsetunset.php
  *
  * @param mixed $offset <p>
  *                      The offset to unset.
  *                      </p>
  *
  * @return void
  */
 public function offsetUnset($offset)
 {
     $this->data->removeKey($offset);
 }