sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function parse_array_rules( array $rules ) { $parse_rules = []; foreach ( $rules as $key => $value ) { if ( is_int( $key ) ) { $parse_rules[] = [ $this->normalize( $value ), [] ]; continue; } $key = $this->normalize( $key ); if ( ! is_array( $value ) ) { $value = [ $value ]; ...
Parse an array based rule. @param array $rules Array rules set. @return array
entailment
protected function parse_string_rules( $rules ) { $split_rules = explode( '|', $rules ); $parse_rules = []; foreach ( $split_rules as $rule ) { $parameters = []; // Format rule and parameters follows {rule}:{parameters}. if ( strpos( $rule, ':' ) !== false ) { list( $rule, $parameter ) = explode( '...
Parse a string based rules. @param string $rules String rules set. @return array
entailment
public function handleConfig($routeId, $path, $result, UserContext $context) { $availableMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']; foreach ($result as $version) { // check version $ver = isset($version['version']) ? intval($version['version']) : 0; if ...
Method which handles data change of each API method. Basically an API method can only change if it is in development mode. In every other case we can only change the status @param integer $routeId @param string $path @param \PSX\Record\RecordInterface $result
entailment
public function authenticateUser($username, $password, array $status) { if (empty($password)) { return null; } // allow login either through username or email if (preg_match('/' . BackendSchema\User::NAME_PATTERN . '/', $username)) { $column = 'name'; ...
Authenticates a user based on the username and password. Returns the user id if the authentication was successful else null @param string $username @param string $password @param array $status @return integer|null
entailment
public function getDefaultScopes() { $scopes = $this->configService->getValue('scopes_default'); return array_filter(array_map('trim', Service\Scope::split($scopes)), function ($scope) { // we filter out the backend scope since this would be a major // security issue ...
Returns the default scopes which every new user gets automatically assigned @return array
entailment
protected function yearOrYearNo($year) { if (is_scalar($year)) { return $this->getYear($year); } if (!$year instanceof Year) { throw new InvalidArgumentException( '$year must be an instance of BmCalendar\Year; got "' . get_class($year) . '"' ...
Checks the type of the provided parameter and returns the appropriate Year. @param int|Year $year @return Year @throws InvalidArgumentException
entailment
public function getMonth($year, $monthNo) { $year = $this->yearOrYearNo($year); return new Month($year, $monthNo); }
Returns the appropriate Month object. @param int|Year $year @param int $monthNo @return Month
entailment
public function getMonths($year) { $year = $this->yearOrYearNo($year); $months = array(); for ($monthNo = 1; $monthNo <= 12; $monthNo++) { $months[$monthNo] = new Month($year, $monthNo); } return $months; }
Get this months for the given year. @param int|Year $year @return Month[]
entailment
public function getDay(Month $month, $dayNo) { $dayNo = (int) $dayNo; if (null === $this->dayProvider) { return new Day($month, $dayNo); } $day = $this->dayProvider->createDay($month, $dayNo); if (!$day instanceof DayInterface) { throw new DomainExc...
Returns the requested day object. @param Month $month @param int $dayNo @return DayInterface
entailment
public function getDays(Month $month) { $days = array(); for ($dayNo = 1; $dayNo <= $month->numberOfDays(); $dayNo++) { $days[$dayNo] = $this->getDay($month, $dayNo); } return $days; }
Returns all the days for the given month. @param Month $month @return DayInterface[]
entailment
private function getPathFromUri($uri) { $uriParser = new UriParser($uri); // Prepare uri $uriParser->encode(); $uri = $uriParser->stripFragment(); if (strpos($uri, '/') === 0) { // URI is already an path return $uri; } if (!$uriParser->...
Get path and query @param string $uri @return string @throws \InvalidArgumentException
entailment
private function isBetween($timestamp, $fromTime, $toTime, $format = 'Hi') { $dateTime = new DateTime(); $timezone = new DateTimeZone('UTC'); $dtRef = $dateTime->createFromFormat('U', $timestamp, $timezone); $dtFrom = $dateTime->createFromFormat($format, $fromTime, $timezone); ...
Is time between @param int $timestamp @param string $fromTime @param string $toTime @param string $format @return bool
entailment
private function checkPaths($path, array $paths) { $reserved = [ '?' => '\?', '.' => '\.', '*' => '.*', '+' => '\+', '(' => '\(', ')' => '\)', '[' => '\[', ']' => '\]', ]; $errorHandler = new Erro...
Check path rule @param string $path @param string[] $paths @return int|false
entailment
public function add_rule( $name, $rules ) { $parsed = ( new Validation_Parser() )->parse( $rules ); foreach ( $parsed as $rule ) { $this->rule( $rule[0], $name, ...$rule[1] ); } return $this; }
Add a single validation rule. @param string $name The field name. @param array|string $rules The rules. @return $this
entailment
public function add_rules( array $rules ) { foreach ( $rules as $name => $rule ) { $this->add_rule( $name, $rule ); } return $this; }
Sets a multiple rules for the validation. @param array $rules Array rules. @return $this
entailment
public function handle(Delay\ManageInterface $handler) { return $handler->base($this->base, $this->product, $this->getValue()); }
Handle delay @param Delay\ManageInterface $handler @return Delay\BaseInterface
entailment
public function jsonSerialize() { return array( 'type' => $this->getType(), 'bodyText' => $this->getBodyText(), 'bodyHtml' => $this->getBodyHtml(), 'recipients' => $this->getRecipients(), 'from' => $this->getFrom(), 'subject' => $thi...
Specify data which should be serialized to JSON @link http://php.net/manual/en/jsonserializable.jsonserialize.php @return mixed data which can be serialized by <b>json_encode</b>, which is a value of any type other than a resource. @since 5.4.0
entailment
private function rmdir($dir) { // remove all files $files = scandir($dir); foreach ($files as $file) { if ($file == '.' || $file == '..') { continue; } $path = $dir . '/' . $file; if (is_dir($path)) { $this->rmd...
Removes all files inside a directory recursively @param string $dir
entailment
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('four_labs_gamp'); $rootNode ->children() ->integerNode('protocol_version') ->defaultValue(1) ->end() ->s...
{@inheritdoc}
entailment
protected function _initSelect() { $request = $this->_objectManager->get('Magento\Framework\App\RequestInterface'); $this->getSelect()->from(['main_table' => $this->getMainTable()]); if(!empty($customerId = $request->getParam('id'))) { $this->getSelect()->where('customer_id = ?'...
Init collection select @return $this
entailment
public function isVisitTime($timestamp = null) { $timestamp = is_int($timestamp) ? $timestamp : time(); foreach ($this->times as $time) { if ($this->isBetween($timestamp, $time['from'], $time['to'], 'Hi')) { return true; } } return empty($this-...
Is visit-time @param int|null $timestamp @return bool
entailment
public function hasSchema($schemaId) { $sql = ' SELECT COUNT(resp.id) AS cnt FROM fusio_routes_response resp INNER JOIN fusio_routes_method method ON resp.method_id = method.id INNER JOIN fusio_routes routes ...
Returns whether a schema id is in use by a route. In the worst case this gets reported by the database constraints but we use this method to report a proper error message @param integer $schemaId @return boolean
entailment
public function hasAction($actionId) { $sql = ' SELECT COUNT(method.id) AS cnt FROM fusio_routes_method method INNER JOIN fusio_routes routes ON routes.id = method.route_id WHERE routes.status = 1 AN...
Returns whether a action id is in use by a route. In the worst case this gets reported by the database constraints but we use this method to report a proper error message @param integer $actionId @return boolean
entailment
public function getMethods($routeId, $version = null, $active = true, $cache = false) { $fields = ['method.id', 'method.route_id', 'method.version', 'method.status', 'method.method', 'method.active', 'method.public', 'method.description', 'method.parameters', 'method.request', 'method.action', 'method.costs...
Returns only active methods for the route @param integer $routeId @param integer $version @param boolean $active @param boolean $cache @return array
entailment
public function sanitization( $value ) { return Utils::sanitize_recursive( $this->parse_value( $value ), function ( $_value ) { return sanitize_text_field( wp_unslash( $_value ) ); } ); }
{@inheritdoc}
entailment
public function parse_value( $value ) { if ( is_array( $this->defaults ) ) { $value = is_array( $value ) ? wp_parse_args( $value, $this->defaults ) : $this->defaults; } return $value; }
Parse the value, merge with $defaults. @param mixed $value @return array|mixed
entailment
public function detectWithCommon($uri, array $customParam = []) { $pairs = array_merge_recursive( $this->cleanParam, $this->appendPath($this->commonParam), $this->appendPath($customParam) ); return $this->parse($uri, $pairs); }
Has robots.txt defined dynamic or common dynamic parameters check @param string $uri @param string[] $customParam @return string[]
entailment
protected function parse($uri, array $pairs) { $path = $this->getPathFromUri($uri); $result = []; foreach ($pairs as $param => $paths) { if (( strpos($uri, "?$param=") || strpos($uri, "&$param=") ) && $this->...
Parse uri and return detected parameters @param string $uri @param array $pairs @return string[]
entailment
private function request($options = []) { $curl = curl_init(); $caPathOrFile = CaBundle::getSystemCaRootBundlePath(); // Set default cURL options curl_setopt_array($curl, [ CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_ENCODING...
cURL request @param array $options @return bool
entailment
public function getStatusCode() { $statusCodeParser = new StatusCodeParser($this->rawStatusCode, parse_url($this->effective, PHP_URL_SCHEME)); return $statusCodeParser->isValid() ? $this->rawStatusCode : null; }
Status code @return int|null
entailment
public function nextUpdate() { if ($this->rawStatusCode === 503 && strpos($this->base, 'http') === 0 ) { return $this->time + min(self::CACHE_TIME, $this->headerParser->getRetryAfter($this->time)); } return $this->time + self::CACHE_TIME; }
Next update timestamp @return int
entailment
private function sort() { if ($this->sort) { return $this->sort; }; return $this->sort = array_multisort($this->cleanParam) && ksort($this->cleanParam); }
Sort by length @return bool
entailment
public function add($line) { $path = '/'; // split into parameter and path $array = array_map('trim', mb_split('\s+', $line, 2)); if (isset($array[1])) { // strip any invalid characters from path prefix $uriParser = new UriParser(preg_replace('/[^A-Za-z0-9\.-\...
Add @param string $line @return bool
entailment
public function render(RenderHandler $handler) { $this->sort(); return $handler->getLevel() == 2 ? $this->renderExtensive($handler) : $this->renderCompressed($handler); }
Render @param RenderHandler $handler @return bool
entailment
private function renderExtensive(RenderHandler $handler) { foreach ($this->cleanParam as $param => $paths) { foreach ($paths as $path) { $handler->add(self::DIRECTIVE_CLEAN_PARAM, $param . ' ' . $path); } } return true; }
Render extensive @param RenderHandler $handler @return bool
entailment
private function renderCompressed(RenderHandler $handler) { $pair = $this->cleanParam; while (($currentPair = current($pair)) !== false) { $equalParams = array_keys($pair, $currentPair); foreach ($currentPair as $path) { $handler->add(self::DIRECTIVE_CLEAN_PAR...
Render compressed @param RenderHandler $handler @return bool
entailment
public function setParams($arr = []) { foreach ($arr as $key => $value) { $this->params[$key] = $value; } }
/* Sets custom params @param array $arr @return void
entailment
private function generate($level, $eol) { $handler = new RenderHandler($level, $eol); if ($level == 2) { $this->root->userAgent->render($handler); } $this->root->host->render($handler); $this->root->cleanParam->render($handler); $this->root->sitemap->rende...
Generate an rule string array @param int $level @param string $eol @return string
entailment
public function execute() { $mailId = $this->_request->getParam('id'); $this->_mail = $this->_objectManager->get('\Shockwavemk\Mail\Base\Model\Mail'); $this->_mail->load($mailId); $this->_view->loadLayout(); $this->_view->getPage()->getConfig()->getTitle()->prepend(__($this-...
Preview Newsletter template @return void|$this
entailment
public function addChild(RoleInterface $role) { if (!$this->hasChild($role)) { $role->setParent($this); $this->children->add($role); } }
{@inheritdoc}
entailment
public function removeChild(RoleInterface $role) { if ($this->hasChild($role)) { $role->setParent(null); $this->children->removeElement($role); } }
{@inheritdoc}
entailment
public function addPermission(PermissionInterface $permission) { if (!$this->hasPermission($permission)) { $this->permissions->add($permission); } }
{@inheritdoc}
entailment
public function removePermission(PermissionInterface $permission) { if ($this->hasPermission($permission)) { $this->permissions->removeElement($permission); } }
{@inheritdoc}
entailment
protected function getWsdlElementAttributes($comment) { $nillable = $minOccurs = $maxOccurs = null; if (preg_match('/{(.+)}/', $comment, $attr)) { if (preg_match_all('/((\w+)\s*=\s*(\w+))/mi', $attr[1], $attr)) { foreach ($attr[2] as $id => $prop) { $p...
Parse attributes nillable, minOccurs, maxOccurs @param string $comment Extracted PHPDoc comment @return array
entailment
protected function injectDom(\DOMDocument $dom, \DOMElement $target, \DOMNode $source) { if ($source->nodeType != XML_ELEMENT_NODE) { return; } $import = $dom->createElement($source->nodeName); foreach ($source->attributes as $attr) { $import->setAttribute($a...
Import custom XML source node into WSDL document under specified target node @param \DOMDocument $dom XML WSDL document being generated @param \DOMElement $target XML node, to which will be appended $source node @param \DOMNode $source Source XML node to be imported
entailment
public function buildHtmlDocs($return = false) { $html = '<html><head>'; $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; $html .= '<style type="text/css"> table{border-collapse: collapse;background-color: #DDDDDD;} tr{background-color: #FFFFFF;} th{backgroun...
Generate human friendly HTML documentation for complex data types. This method can be invoked either by inserting URL parameter "&makedoc" into URL link, e.g. "http://www.mydomain.com/soap/create?makedoc", or simply by calling from another script with argument $return=true. Each complex data type is described in a sep...
entailment
public function supports(ExampleNode $example): bool { return count($this->getRequirements($this->getDocComment($example))) > 0; }
{@inheritdoc}
entailment
public function prepare( ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators ): void { foreach ($this->getRequirements($this->getDocComment($example)) as $requirement) { if (!class_exists($requirement) && !int...
{@inheritdoc}
entailment
private function getRequirements(string $docComment): array { return array_map( function($tag) { preg_match('#@require ([^ ]*)#', $tag, $match); return $match[1]; }, array_filter( array_map( 'trim', ...
Get required interfaces @param string $docComment @return array
entailment
public function client() { return new HostClient($this->base, $this->effective, isset($this->host[0]) ? [$this->host[0]] : []); }
Client @return HostClient
entailment
public function render(RenderHandler $handler) { if (isset($this->host[0])) { $handler->add(self::DIRECTIVE_HOST, $this->host[0]); } return true; }
Render @param RenderHandler $handler @return bool
entailment
protected function initFilters() { if (!empty($this->filters)) { foreach ($this->filters as $name => $handler) { $this->addFilter($name, $handler); } } }
Add custom filters from ViewRenderer `filters` parameter.
entailment
protected function initCachePath() { $cachePath = empty($this->cachePath) ? false : Yii::getAlias($this->cachePath); if (!empty($cachePath) && !file_exists($cachePath)) { FileHelper::createDirectory($cachePath); } return $cachePath; }
Create if needed and return the cache path calculated from ViewRenderer `cachePath` parameter. @throws \yii\base\Exception @return bool|string
entailment
public function init() { $cachePath = $this->initCachePath(); // @codeCoverageIgnoreStart if (!empty($cachePath) && !is_readable($cachePath)) { throw new Exception(Yii::t('app', 'Pug cache path is not readable.')); } if (!empty($cachePath) && !is_writable($cache...
Create the pug renderer engine. @throws Exception @throws \yii\base\Exception
entailment
public function render($view, $file, $params) { $method = method_exists($this->pug, 'renderFile') ? [$this->pug, 'renderFile'] : [$this->pug, 'render']; // @codeCoverageIgnoreStart if ($this->pug instanceof \Tale\Pug\Renderer && !($this->pug instanceof \Phug\Renderer)...
Renders a view file. This method is invoked by [[View]] whenever it tries to render a view. Child classes must implement this method to render the given view file. @param View $view the view object used for rendering the file. @param string $file the view file. @param array $params the parameters to be passed ...
entailment
public function addFilter($name, $handler) { if (is_string($handler) && !is_callable($handler)) { $handler = new $handler(); } $this->pug->filter($name, $handler); }
Adds custom filter. @param string $name @param callable $handler
entailment
public function execute() { // Get request data $mailId = $this->_request->getParam('id'); $recalculate = $this->_request->getParam('resend_type'); // Email address to re-send mail $email = $this->_request->getParam('email'); /** @var \Shockwavemk\Mail\Base\Model\Ma...
Resend mail @return void|$this
entailment
protected function deriveTransportBuilderFromExistingMail($mail) { return $this->transportBuilder ->setTemplateIdentifier($mail->getTemplateIdentifier()) ->setTemplateOptions(['area' => Area::AREA_FRONTEND, 'store' => $mail->getStoreId()]) ->setTemplateVars($mail->getVars...
TODO @param \Shockwavemk\Mail\Base\Model\Mail $mail @return TransportBuilder @throws \Magento\Framework\Exception\MailException
entailment
public function getStyle() { $style = ''; // Always add fixed height as a fallback if autosetting or JS fails. $height = $this->FixedHeight; if (!$height) { $height = 800; } $style .= "height: {$height}px; "; if ($this->AutoWidth) { $...
Compute style from the size parameters.
entailment
public function validate() { $result = parent::validate(); //whitelist allowed URL schemes $allowed_schemes = array('http', 'https'); if ($matches = parse_url($this->IFrameURL)) { if (isset($matches['scheme']) && !in_array($matches['scheme'], $allowed_schemes)) { ...
Ensure that the IFrameURL is a valid url and prevents XSS @throws ValidationException @return ValidationResult
entailment
protected function prepareMessage() { $template = $this->getTemplate(); $types = [ TemplateTypesInterface::TYPE_TEXT => MessageInterface::TYPE_TEXT, TemplateTypesInterface::TYPE_HTML => MessageInterface::TYPE_HTML, ]; // Bugfix for not translated cron schedu...
Prepare message @return $this @throws \Zend_Mail_Exception
entailment
public function getMail() { /** @noinspection IsEmptyFunctionUsageInspection */ if (empty($this->_mail)) { $this->_mail = $this->objectManager ->create('Shockwavemk\Mail\Base\Model\Mail'); /** @var \Shockwavemk\Mail\Base\Model\Mail\AttachmentCollection $attac...
Get mail @return \Shockwavemk\Mail\Base\Model\Mail @throws \Magento\Framework\Exception\MailException
entailment
public function setFrom($from) { $result = $this->_senderResolver->resolve($from, $this->getStoreId()); $this->setSenderMail($result); $this->message->setFrom($result['email'], $result['name']); return $this; }
Set mail from address @param string|array $from @return $this @throws \Magento\Framework\Exception\MailException
entailment
public function execute() { $encodedId = $this->_request->getParam('id'); /** @var \Shockwavemk\Mail\Base\Model\Mail $_mail */ $mail = $this->_objectManager->get('\Shockwavemk\Mail\Base\Model\Mail'); $mail->load(base64_decode($encodedId)); $encodedPath = $this->_request->ge...
Preview Newsletter template @return void|$this
entailment
public static function compare(LocaleInterface $x, LocaleInterface $y) { return strcmp($x->endonymSortable(), $y->endonymSortable()); }
Callback for PHP sort functions - allows lists of locales to be sorted. Diacritics are removed and text is capitalized to allow fast/simple sorting. @param LocaleInterface $x @param LocaleInterface $y @return int
entailment
public static function create($code) { $class = __NAMESPACE__ . '\Locale\Locale' . implode(array_map(function ($x) { return ucfirst(strtolower($x)); }, preg_split('/[^a-zA-Z0-9]+/', $code))); if (class_exists($class)) { return new $class(); } throw n...
Create a locale from a language tag (or locale code). @param string $code @return LocaleInterface @throws DomainException
entailment
public static function httpAcceptLanguage(array $server, array $available, LocaleInterface $default) { if (!empty($server['HTTP_ACCEPT_LANGUAGE'])) { $http_accept_language = strtolower(str_replace(' ', '', $server['HTTP_ACCEPT_LANGUAGE'])); preg_match_all('/(?:([a-z][a-z0-9_-]+)(?:;q...
Create a locale from a language tag (or locale code). @param string[] $server The $_SERVER array @param LocaleInterface[] $available All locales supported by the application @param LocaleInterface $default Locale to show in no matching locales @return LocaleInterface
entailment
private static function httpAcceptDowngrade($preferences) { foreach ($preferences as $code => $priority) { // Three parts: "zh-hans-cn" => "zh-hans" and "zh" if (preg_match('/^(([a-z]+)-[a-z]+)-[a-z]+$/', $code, $match)) { if (!isset($preferences[$match[2]])) { ...
If a client requests "de-DE" (but not "de"), then add "de" as a lower-priority fallback. @param $preferences @return int[]
entailment
private static function httpAcceptChinese($preferences) { foreach (self::$http_accept_chinese as $old => $new) { if (array_key_exists($old, $preferences) && !array_key_exists($new, $preferences)) { $preferences[$new] = $preferences[$old] * 0.5; } } re...
Some browsers allow the user to select "Chinese (simplified)", but then use zh-CN instead of zh-Hans. This goes against the advice of w3.org. @param int[] $preferences @return int[]
entailment
public function get_field( $field, $field_group = null, $deprecated = false ) { if ( $field instanceof \CMB2_Field ) { $field = $field->id( true ); } $field = is_array( $field ) ? $field['id'] : (string) $field; if ( $field_group ) { return $this->get_field_in_group( $field_group, $field ); } retur...
{@inheritdoc}
entailment
public function get_field_in_group( $field_group, $sub_field ) { if ( ! $field_group instanceof Field_Contract ) { $field_group = $this->get_field( $field_group ); } if ( ! $field_group || 'group' !== $field_group->get_type() ) { return null; } $sub_fields = $field_group->prop( 'fields', [] ); if (...
Gets a field in a group. @param \WPLibs\Form\Contracts\Field|string $field_group @param string $sub_field @return \WPLibs\Form\Contracts\Field|null
entailment
public function get_field_raw( $field ) { if ( array_key_exists( $field, $this->prop( 'fields' ) ) ) { return $this->prop( 'fields' )[ $field ]; } return null; }
Return the field raw @param string $field @return array|null
entailment
protected function get_new_field( $field_args, $field_group = null ) { if ( 'group' === $field_args['type'] ) { return new Field_Group( $this, $this->get_default_args( $field_args ) ); } return new Field( $this, $this->get_default_args( $field_args, $field_group ) ); }
{@inheritdoc}
entailment
public function get($type) { if ($type === self::TYPE_MAILER) { $name = $this->configService->getValue('system_mailer'); } elseif ($type === self::TYPE_DISPATCHER) { $name = $this->configService->getValue('system_dispatcher'); } else { throw new \InvalidAr...
Returns a configured connection from the provided type @param string $type @return mixed|null
entailment
public function add_group( $args, $position = 0 ) { $args['type'] = 'group'; $id = $this->add_field( $args, $position ); return new Group_Builder( $this, $id ); }
{@inheritdoc}
entailment
public function skip_fill_types( $types ) { $this->skip_fill_types = array_unique( array_merge( $this->skip_fill_types, $types ) ); return $this; }
{@inheritdoc}
entailment
public function set_option( $name, $value ) { $this->throws_if_locked(); $this->set_prop( $name, $value ); return $this; }
{@inheritdoc}
entailment
protected function initSources(array $sources) { foreach ($sources as $source) { $this->sources[] = new EntitySource($this, $source); } }
Populate the sources array. This is called from the constructor, and can be overridden in subclasses. @param array $sources The sources as an array of \SimpleSAML\Configuration objects. @return void
entailment
public static function getAggregator($id) { assert('is_string($id)'); $config = Configuration::getConfig('module_aggregator2.php'); return new Aggregator($id, $config->getConfigItem($id)); }
Return an instance of the aggregator with the given id. @param string $id The id of the aggregator. @return Aggregator
entailment
public function addCacheItem($id, $data, $expires, $tag = null) { assert('is_string($id)'); assert('is_string($data)'); assert('is_int($expires)'); assert('is_null($tag) || is_string($tag)'); $cacheFile = strval($this->cacheDirectory).'/'.$id; try { Syste...
Add an item to the cache. @param string $id The identifier of this data. @param string $data The data. @param int $expires The timestamp the data expires. @param string|null $tag An extra tag that can be used to verify the validity of the cached data. @return void
entailment
public function isCacheValid($id, $tag = null) { assert('is_string($id)'); assert('is_null($tag) || is_string($tag)'); $cacheFile = strval($this->cacheDirectory).'/'.$id; if (!file_exists($cacheFile)) { return false; } $expireFile = $cacheFile.'.expire';...
Check validity of cached data. @param string $id The identifier of this data. @param string $tag The tag that was passed to addCacheItem. @return bool TRUE if the data is valid, FALSE if not.
entailment
public function getCacheItem($id, $tag = null) { assert('is_string($id)'); assert('is_null($tag) || is_string($tag)'); if (!$this->isCacheValid($id, $tag)) { return null; } $cacheFile = strval($this->cacheDirectory).'/'.$id; return @file_get_contents($ca...
Get the cache item. @param string $id The identifier of this data. @param string $tag The tag that was passed to addCacheItem. @return string|null The cache item, or NULL if it isn't cached or if it is expired.
entailment
public function getCacheFile($id) { assert('is_string($id)'); $cacheFile = strval($this->cacheDirectory).'/'.$id; if (!file_exists($cacheFile)) { return null; } return $cacheFile; }
Get the cache filename for the specific id. @param string $id The identifier of the cached data. @return string|null The filename, or NULL if the cache file doesn't exist.
entailment
protected function addSignature(SignedElement $element) { if ($this->signKey === null) { return; } /** @var string $this->signAlg */ $privateKey = new XMLSecurityKey($this->signAlg, ['type' => 'private']); if ($this->signKeyPass !== null) { $privateKe...
Sign the generated EntitiesDescriptor. @return void
entailment
private static function extractEntityDescriptors(EntitiesDescriptor $entity) { $results = []; foreach ($entity->children as $child) { if ($child instanceof EntityDescriptor) { $results[] = $child; continue; } $results = array_merge...
Recursively browse the children of an EntitiesDescriptor element looking for EntityDescriptor elements, and return an array containing all of them. @param \SAML2\XML\md\EntitiesDescriptor $entity The source EntitiesDescriptor that holds the entities to extract. @return array An array containing all the EntityDescript...
entailment
protected function getEntitiesDescriptor() { $ret = new EntitiesDescriptor(); $now = time(); // add RegistrationInfo extension if enabled if (!empty($this->regInfo)) { $ri = new RegistrationInfo(); $ri->registrationInstant = $now; foreach ($this->...
Retrieve all entities as an EntitiesDescriptor. @return \SAML2\XML\md\EntitiesDescriptor The entities.
entailment
protected function exclude(EntitiesDescriptor $descriptor) { if (empty($this->excluded)) { return $descriptor; } $filtered = []; foreach ($descriptor->children as $child) { if ($child instanceof EntityDescriptor) { if (in_array($child->entityI...
Recursively traverse the children of an EntitiesDescriptor, removing those entities listed in the $entities property. Returns the EntitiesDescriptor with the entities filtered out. @param \SAML2\XML\md\EntitiesDescriptor $descriptor The EntitiesDescriptor from where to exclude entities. @return \SAML2\XML\md\Entities...
entailment
protected function filter(EntitiesDescriptor $descriptor) { if ($this->roles === null || $this->protocols === null) { return $descriptor; } $enabled_roles = array_keys($this->roles, true); $enabled_protos = array_keys($this->protocols, true); $filtered = []; ...
Recursively traverse the children of an EntitiesDescriptor, keeping only those entities with the roles listed in the $roles property, and support for the protocols listed in the $protocols property. Returns the EntitiesDescriptor containing only those entities. @param \SAML2\XML\md\EntitiesDescriptor $descriptor The E...
entailment
public function excludeEntities($entities) { assert('is_array($entities) || is_null($entities)'); if ($entities === null) { return; } $this->excluded = $entities; sort($this->excluded); $this->cacheId = sha1($this->cacheId.serialize($this->excluded)); ...
Set this aggregator to exclude a set of entities from the resulting aggregate. @param array|null $entities The entity IDs of the entities to exclude. @return void
entailment
public function setFilters($set) { assert('is_array($set) || is_null($set)'); if ($set === null) { return; } // configure filters $this->protocols = [ Constants::NS_SAMLP => true, 'urn:oasis:names:tc:SAML:1.1:protocol' ...
Set the internal filters according to one or more options: - 'saml2': all SAML2.0-capable entities. - 'shib13': all SHIB1.3-capable entities. - 'saml20-idp': all SAML2.0-capable identity providers. - 'saml20-sp': all SAML2.0-capable service providers. - 'saml20-aa': all SAML2.0-capable attribute authorities. - 'shib13...
entailment
public function updateCachedMetadata() { $ed = $this->getEntitiesDescriptor(); $ed = $this->exclude($ed); $ed = $this->filter($ed); $this->addSignature($ed); $xml = $ed->toXML(); $xml = $xml->ownerDocument->saveXML($xml); if ($this->cacheGenerated !== null) ...
Retrieve the complete, signed metadata as text. This function will write the new metadata to the cache file, but will not return the cached metadata. @return string The metadata, as text.
entailment
public function getMetadata() { if ($this->cacheGenerated !== null) { $xml = $this->getCacheItem($this->cacheId, $this->cacheTag); if ($xml !== null) { Logger::debug($this->logLoc.'Loaded generated metadata from cache.'); return $xml; } ...
Retrieve the complete, signed metadata as text. @return string The metadata, as text.
entailment
public function add($directive, $line) { $this->previous = $this->directive; $this->directive = $directive; $this->strings[] = rtrim($this->prefix() . $line); return true; }
Add line @param string $directive @param string $line @return bool
entailment
private function prefix() { $result = $this->lineBreak() . $this->directive . ':'; if ($this->level === 0) { return $result; } return ucwords($result) . ' '; }
Advanced beautifier @return string
entailment
private function lineBreak() { if ($this->previousRoot !== $this->directive && in_array($this->directive, array_keys(RobotsTxtParser::TOP_LEVEL_DIRECTIVES)) || $this->previous !== self::DIRECTIVE_USER_AGENT && $this->directive === self::DIRECTIVE_USER_AGENT ) { ...
Returns an line separator if required @return string
entailment
public function getConfig() { if ($this->config) { return $this->config; } $config = $this->getDefaultConfig(); // read from database $result = $this->connection->fetchAll('SELECT type, class FROM fusio_provider ORDER BY class ASC'); foreach ($result as ...
Returns the provider config of the system @return \Fusio\Impl\Provider\ProviderConfig
entailment
public function write($cacheFile, $content) { // 添加写入时间 $content = $_SERVER['REQUEST_TIME'] . $content; if (!$this->mc->set($cacheFile, $content, 0)) { throw new Exception('sae mc write error:' . $cacheFile); } else { $this->contents[$cacheFile] = $content; ...
写入编译缓存 @param string $cacheFile 缓存的文件名 @param string $content 缓存的内容 @return void|array
entailment
public function read($cacheFile, $vars = []) { if (!empty($vars) && is_array($vars)) { extract($vars, EXTR_OVERWRITE); } eval('?>' . $this->get($cacheFile, 'content')); }
读取编译编译 @param string $cacheFile 缓存的文件名 @param array $vars 变量数组 @return void
entailment
public function check($cacheFile, $cacheTime) { $mtime = $this->get($cacheFile, 'mtime'); if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > $mtime + $cacheTime) { // 缓存是否在有效期 return false; } return true; }
检查编译缓存是否有效 @param string $cacheFile 缓存的文件名 @param int $cacheTime 缓存时间 @return boolean
entailment
private function get($filename, $name) { if (!isset($this->contents[$filename])) { $this->contents[$filename] = $this->mc->get($filename); } $content = $this->contents[$filename]; if (false === $content) { return false; } $info = array( ...
读取文件信息 @access private @param string $filename 文件名 @param string $name 信息名 mtime或者content @return boolean
entailment