/** * 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; }
/** * 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; }
/** * Removes the route under the given name. * * @param string $name Route name. * * @return $this */ public function remove($name) { return $this->routes->removeKey($name); }
/** * Override __unset * * @param string $name * * @return void */ public function __unset($name) { if ($this->data->keyExists($name)) { $this->data->removeKey($name); } }
/** * 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; }
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()); }
/** * (PHP 5 >= 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); }