sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
private function optimizeDirs() { $this->optimizedDirs = []; foreach ($this->dirs as $pathname) { $pathname = \BearFramework\Internal\Utilities::normalizePath($pathname); if (substr($pathname, -3) !== '://') { $pathname = rtrim($pathname, '/') . '/'; ...
Must be called before using $this->optimizedDirs
entailment
public function getURL(string $filename, array $options = []): string { $filename = \BearFramework\Internal\Utilities::normalizePath($filename); $url = null; if ($this->hasEventListeners('beforeGetURL')) { $eventDetails = new \BearFramework\App\Assets\BeforeGetURLEventDetails($fi...
Returns a public URL for the specified filename. @param string $filename The filename. @param array $options URL options. You can resize the file by providing "width", "height" or both. @throws \InvalidArgumentException @return string The URL for the specified filename and options.
entailment
public function getContent(string $filename, array $options = []): ?string { if (!empty($options)) { $this->validateOptions($options); } $urlOptions = []; if (isset($options['width'])) { $urlOptions['width'] = $options['width']; } if (isset($op...
Returns the content of the file specified. @param string $filename The filename. @param array $options List of options. You can resize the file by providing "width", "height" or both. You can specify encoding too (base64, data-uri, data-uri-base64). @throws \InvalidArgumentException @return string|null The content of ...
entailment
public function getResponse(\BearFramework\App\Request $request): ?\BearFramework\App\Response { $parsePath = function($path) { if (strpos($path, $this->internalPathPrefix) !== 0) { return null; } $path = substr($path, strlen($this->internalPathPrefix)); ...
Creates a response object for the asset request. @param \BearFramework\App\Request $request The request object to match against. @return \BearFramework\App\Response|null The response object for the request specified.
entailment
private function prepare(string $filename, array $options = []): ?string { if (!empty($options)) { $this->validateOptions($options); } $result = null; if ($this->hasEventListeners('beforePrepare')) { $eventDetails = new \BearFramework\App\Assets\BeforePrepar...
Prepares a local filename that will be returned for the file requested. @param string $filename The filename to prepare. @param array $options A list of options for the filename. @return string|null The local filename of the prepared file or null.
entailment
public function getDetails(string $filename, array $list): array { $result = null; if ($this->hasEventListeners('beforeGetDetails')) { $eventDetails = new \BearFramework\App\Assets\BeforeGetDetailsEventDetails($filename, $list); $this->dispatchEvent('beforeGetDetails', $event...
Returns a list of details for the filename specified. @param string $filename The filename of the asset. @param array $list A list of details to return. Available values: mimeType, size, width, height. @return array A list of tails for the filename specified.
entailment
private function getImageSize(string $filename): array { $result = [null, null]; try { $size = getimagesize($filename); if (is_array($size)) { $result = [(int) $size[0], (int) $size[1]]; } elseif (pathinfo($filename, PATHINFO_EXTENSION) === 'webp' ...
Returns the size (if available) of the asset specified. @param string $filename The filename of the asset. @return array[int|null,int|null] The size of the asset specified.
entailment
private function resize(string $sourceFilename, string $destinationFilename, array $options = []): void { if (!is_file($sourceFilename)) { throw new \InvalidArgumentException('The sourceFilename specified does not exist (' . $sourceFilename . ')'); } if (isset($options['width']) ...
Resizes an asset file. @param string $sourceFilename The asset file to resize. @param string $destinationFilename The filename where the result asset will be saved. @param array $options Resize options. You can resize the file by providing "width", "height" or both. @throws \InvalidArgumentException @throws \Exception...
entailment
private function getMimeType(string $filename) { $pathinfo = pathinfo($filename); if (isset($pathinfo['extension'])) { $extension = strtolower($pathinfo['extension']); $mimeTypes = array( '3dml' => 'text/vnd.in3d.3dml', '3ds' => 'image/x-3ds', ...
Finds the mime type of a filename by checking it's extension. @param string $filename The filename. @return string|null The mimetype of the filename specified.
entailment
public static function get($key = null) { if (null === self::$instance) { self::$instance = new self(); } return $key ? self::$instance[$key] : self::$instance; }
Returns the application singleton. @param string $key A service or parameter key. @return Go The application singleton.
entailment
public function registerUpdater() { $this->register( new UpdateServiceProvider(), array('update_url' => '@manifest_url@') ); $app = $this; $command = $this->add( 'update', function ( InputInterface $input, ...
Allows the application to be updated. @return Go The application.
entailment
public function loadClassMetadata(ClassMetadataInterface $classMetadata) { $result = false; foreach ($this->loaders as $loader) { $result = $loader->loadClassMetadata($classMetadata) || $result; } return $result; }
{@inheritdoc}
entailment
public function getMappedClasses() { $classes = []; foreach ($this->loaders as $loader) { if ($loader instanceof MappedClassMetadataLoaderInterface) { $classes = array_merge($classes, $loader->getMappedClasses()); } } return array_unique($cla...
{@inheritdoc}
entailment
public function convert($data, TypeMetadataInterface $type, ContextInterface $context) { return $context->getVisitor()->visitArray($data, $type, $context); }
{@inheritdoc}
entailment
public function setName($name) { if (!class_exists($name)) { throw new \InvalidArgumentException(sprintf('The class "%s" does not exist.', $name)); } $this->name = $name; }
{@inheritdoc}
entailment
public function addProperty(PropertyMetadataInterface $property) { $name = $property->getName(); if ($this->hasProperty($name)) { $this->getProperty($name)->merge($property); } else { $this->properties[$name] = $property; } }
{@inheritdoc}
entailment
public function merge(ClassMetadataInterface $classMetadata) { if ($classMetadata->hasXmlRoot()) { $this->setXmlRoot($classMetadata->getXmlRoot()); } foreach ($classMetadata->getProperties() as $property) { $this->addProperty($property); } }
{@inheritdoc}
entailment
public function unserialize($serialized) { list( $this->name, $this->properties, $this->xmlRoot ) = unserialize($serialized); }
{@inheritdoc}
entailment
public function prepare($data, ContextInterface $context) { return $this->decode(parent::prepare($data, $context)); }
{@inheritdoc}
entailment
public function visitBoolean($data, TypeMetadataInterface $type, ContextInterface $context) { return parent::visitBoolean( filter_var($data, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE), $type, $context ); }
{@inheritdoc}
entailment
protected function doVisitObjectProperty( $data, $name, PropertyMetadataInterface $property, ContextInterface $context ) { $type = $property->getType(); if ($type === null) { throw new \RuntimeException(sprintf( 'You must define the type o...
{@inheritdoc}
entailment
public function enableErrorHandler(array $options = []): void { if ($this->errorHandlerEnabled) { throw new \Exception('The error handler is already enabled!'); } set_exception_handler(function($exception) use ($options) { \BearFramework\Internal\ErrorHandler::handleE...
Enables an error handler. @param array $options Error handler options. Available values: logErrors (bool), displayErrors (bool). @return void No value is returned. @throws \Exception
entailment
public function run(): void { $response = $this->routes->getResponse($this->request); if (!($response instanceof App\Response)) { $response = new App\Response\NotFound(); } $this->send($response); }
Call this method to find the response in the registered routes and send it. @return void No value is returned.
entailment
public function send(\BearFramework\App\Response $response): void { if ($this->hasEventListeners('beforeSendResponse')) { $this->dispatchEvent('beforeSendResponse', new \BearFramework\App\BeforeSendResponseEventDetails($response)); } if (!$response->headers->exists('Content-Lengt...
Outputs a response. @param \BearFramework\App\Response $response The response object to output. @return void No value is returned.
entailment
public function initialize(NavigatorInterface $navigator, VisitorInterface $visitor, $direction, $format) { $this ->setNavigator($navigator) ->setVisitor($visitor) ->setDirection($direction) ->setFormat($format) ->setDataStack([]) ->set...
{@inheritdoc}
entailment
public function enterScope($data, MetadataInterface $metadata) { $this->dataStack[] = $data; $this->metadataStack[] = $metadata; return $this; }
{@inheritdoc}
entailment
public function matchesRequest() { $hasImages = ! Collection::make($this->event->get('attachments'))->isEmpty(); return parent::matchesRequest() && $hasImages; }
Determine if the request is for this driver. @return bool
entailment
public function getMessages() { $message = new IncomingMessage(File::PATTERN, $this->event->get('from')['id'], $this->event->get('conversation')['id'], $this->payload); $message->setFiles($this->getAttachmentUrls()); return [$message]; }
Retrieve the chat message. @return array
entailment
public function getAttachmentUrls() { return Collection::make($this->event->get('attachments'))->map(function ($item) { return new File($item['contentUrl'], $item); })->toArray(); }
Retrieve attachment urls from an incoming message. @return array A download for the attachment.
entailment
public function set(string $key, $value, int $ttl = null): void { $keyMD5 = md5($key); $key = $this->keyPrefix . substr($keyMD5, 0, 3) . '/' . substr($keyMD5, 3) . '.2'; $this->dataRepository->setValue($key, gzcompress(serialize([$ttl > 0 ? time() + $ttl : 0, $value]))); }
Stores a value in the cache. @param string $key The key under which to store the value. @param type $value The value to store. @param int $ttl Number of seconds to store value in the cache. @return void No value is returned.
entailment
public function get(string $key) { $keyMD5 = md5($key); $value = $this->dataRepository->getValue($this->keyPrefix . substr($keyMD5, 0, 3) . '/' . substr($keyMD5, 3) . '.2'); if ($value !== null) { try { $value = unserialize(gzuncompress($value)); i...
Retrieves a value from the cache. @param string $key The key under which the value is stored. @return mixed|null Returns the stored value or null if not found or expired.
entailment
public function delete(string $key): void { $keyMD5 = md5($key); $this->dataRepository->delete($this->keyPrefix . substr($keyMD5, 0, 3) . '/' . substr($keyMD5, 3) . '.2'); }
Deletes a value from the cache. @param string $key The key under which the value is stored. @return void No value is returned.
entailment
public function setMultiple(array $items, int $ttl = null): void { foreach ($items as $key => $value) { $this->set($key, $value, $ttl); } }
Stores multiple values in the cache. @param array $items An array of key/value pairs to store in the cache. @param int $ttl Number of seconds to store values in the cache. @return void No value is returned.
entailment
public function clear(): void { $list = $this->dataRepository->getList() ->filterBy('key', $this->keyPrefix, 'startWith'); foreach ($list as $item) { $this->dataRepository->delete($item->key); }; }
Deletes all values from the cache.
entailment
public function convert($data, TypeMetadataInterface $type, ContextInterface $context) { return $context->getVisitor()->visitBoolean($data, $type, $context); }
{@inheritdoc}
entailment
public function get(string $path = '/') { return $this->app->request->base . implode('/', array_map('urlencode', explode('/', $path))); }
Constructs a url for the path specified. @param string $path The path. @return string Absolute URL containing the base URL plus the path given.
entailment
protected function loadFile($file) { $data = []; $xml = simplexml_import_dom($this->loadDocument($file)); foreach ($xml->class as $class) { $data[(string) $class['name']] = $this->loadClass($class); } return $data; }
{@inheritdoc}
entailment
private function loadClass(\SimpleXMLElement $class) { $definition = []; if (isset($class['exclusion-policy'])) { $definition['exclusion_policy'] = (string) $class['exclusion-policy']; } if (isset($class['order'])) { $definition['order'] = (string) $class['o...
@param \SimpleXMLElement $class @return mixed[]
entailment
private function loadProperty(\SimpleXMLElement $element) { $property = []; if (isset($element['alias'])) { $property['alias'] = (string) $element['alias']; } if (isset($element['type'])) { $property['type'] = (string) $element['type']; } if...
@param \SimpleXMLElement $element @return mixed[]
entailment
private function loadDocument($file) { $data = trim(@file_get_contents($file)); if (empty($data)) { throw new \InvalidArgumentException(sprintf('The XML mapping file "%s" is not valid.', $file)); } $internalErrors = libxml_use_internal_errors(); $disableEntities...
@param string $file @return \DOMDocument
entailment
private function createException($file, $internalErrors, $disableEntities) { $errors = []; foreach (libxml_get_errors() as $error) { $errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)', $error->level === LIBXML_ERR_WARNING ? 'WARNING' : 'ERROR', ...
@param string $file @param bool $internalErrors @param bool $disableEntities @return \InvalidArgumentException
entailment
public function add(string $name, callable $callback): self { call_user_func($this->addCallback, $name, $callback); return $this; }
Creates a new shortcut. @param string $name The name of the shortcut property. @param callable $callback The callback to return the shortcut value. @return self Returns a reference to itself.
entailment
public function addDir(string $pathname): self { $this->appAssets->addDir($this->dir . '/' . $pathname); return $this; }
Registers a directory that will be publicly accessible relative to the current addon or application location. @param string $pathname The directory name. @return self Returns a reference to itself.
entailment
public function getURL(string $filename, array $options = []): string { return $this->appAssets->getURL($this->dir . '/' . $filename, $options); }
Returns a public URL for the specified filename in the current context. @param string $filename The filename. @param array $options URL options. You can resize the file by providing "width", "height" or both. @return string The URL for the specified filename and options.
entailment
public function getContent(string $filename, array $options = []): ?string { return $this->appAssets->getContent($this->dir . '/' . $filename, $options); }
Returns the content of the file specified in the current context. @param string $filename The filename. @param array $options List of options. You can resize the file by providing "width", "height" or both. You can specify encoding too (base64 or data-uri). @return string|null The content of the file or null if file d...
entailment
public function getDetails(string $filename, array $list): array { return $this->appAssets->getDetails($this->dir . '/' . $filename, $list); }
Returns a list of details for the filename specifie in the current context. @param string $filename The filename of the asset. @param array $list A list of details to return. Available values: mimeType, size, width, height. @return array A list of tails for the filename specified.
entailment
public function getURL(): ?string { if ($this->base !== null) { $list = []; $queryList = $this->query->getList(); foreach ($queryList as $queryItem) { $list[$queryItem->name] = $queryItem->value; } return $this->base . implode('/', ...
Returns the request URL or null if the base is empty. @return string|null Returns the request URL or null if the base is empty.
entailment
public function matchesRequest() { $hasImages = ! Collection::make($this->event->get('attachments'))->where('contentType', 'image')->isEmpty(); return $hasImages && (! is_null($this->event->get('recipient')) && ! is_null($this->event->get('serviceUrl'))); }
Determine if the request is for this driver. @return bool
entailment
public function getMessages() { if (empty($this->messages)) { $message = new IncomingMessage(Image::PATTERN, $this->event->get('from')['id'], $this->event->get('conversation')['id'], $this->payload); $message->setImages($this->getImagesUrls()); $this->mess...
Retrieve the chat message. @return array
entailment
public function getImagesUrls() { return Collection::make($this->event->get('attachments'))->where('contentType', 'image')->map(function ($item) { return new Image($item['contentUrl'], $item); })->toArray(); }
Retrieve image urls from an incoming message. @return array A download for the image file.
entailment
protected function doVisitObjectProperty( $data, $name, PropertyMetadataInterface $property, ContextInterface $context ) { if (!$property->isReadable()) { return false; } $result = $this->navigator->navigate( $this->accessor->getValue(...
{@inheritdoc}
entailment
public static function create(array $types = []) { $expandedTypes = []; foreach ([Direction::SERIALIZATION, Direction::DESERIALIZATION] as $direction) { $expandedTypes[$direction] = isset($types[$direction]) ? $types[$direction] : []; unset($types[$direction]); } ...
@param TypeInterface[][]|TypeInterface[] $types @return TypeRegistryInterface
entailment
public function registerType($name, $direction, TypeInterface $type) { if (!isset($this->types[$direction])) { $this->types[$direction] = []; } $this->types[$direction][$name] = $type; }
{@inheritdoc}
entailment
public function getType($name, $direction) { if (!isset($this->types[$direction][$name])) { if (!class_exists($name)) { throw new \InvalidArgumentException(sprintf( 'The type "%s" for direction "%s" does not exist.', $name, ...
{@inheritdoc}
entailment
private function findClassType($name, $direction) { if (!isset($this->types[$direction])) { return; } foreach ($this->types[$direction] as $class => $type) { if ((class_exists($class) || interface_exists($class)) && is_a($name, $class, true)) { return...
@param string $name @param int $direction @return TypeInterface|null
entailment
public function loadClassMetadata(ClassMetadataInterface $classMetadata) { return ($loader = $this->getLoader()) !== null && $loader->loadClassMetadata($classMetadata); }
{@inheritdoc}
entailment
public function add($pattern, $callback): self { if (is_string($pattern)) { if (!isset($pattern{0})) { throw new \InvalidArgumentException('The pattern argument must be a not empty string or array of not empty strings'); } $pattern = [$pattern]; } ...
Registers a request handler. @param string|string[] $pattern Path pattern or array of patterns. Can contain "?" (path segment) and "*" (matches everything). Can start with method name (GET, HEAD, POST, DELETE, PUT, PATCH, OPTIONS) or list of method names (GET|HEAD|POST). @param callable|callable[] $callback Function t...
entailment
public function getResponse(\BearFramework\App\Request $request) { $requestPath = (string) $request->path; $requestMethod = $request->method; foreach ($this->data as $route) { foreach ($route[0] as $pattern) { $matches = null; preg_match('/^(?:(?:(...
Finds the matching callback and returns its result. @param \BearFramework\App\Request $request The request object to match against. @return mixed The result of the matching callback. NULL if none.
entailment
protected function getType(&$value) { if (ctype_alpha($value[0])) { return self::T_NAME; } if ($value[0] === '\'') { $value = str_replace('\'\'', '\'', substr($value, 1, -1)); return self::T_STRING; } if ($value === '>') { re...
{@inheritdoc}
entailment
public function skipClass(ClassMetadataInterface $class, ContextInterface $context) { foreach ($this->strategies as $strategy) { if ($strategy->skipClass($class, $context)) { return true; } } return false; }
{@inheritdoc}
entailment
public function skipProperty(PropertyMetadataInterface $property, ContextInterface $context) { foreach ($this->strategies as $strategy) { if ($strategy->skipProperty($property, $context)) { return true; } } return false; }
{@inheritdoc}
entailment
public function skipType(TypeMetadataInterface $type, ContextInterface $context) { foreach ($this->strategies as $strategy) { if ($strategy->skipType($type, $context)) { return true; } } return false; }
{@inheritdoc}
entailment
protected function fetchClassMetadata($class) { $item = $this->pool->getItem(strtr($this->prefix.$class, '\\', '_')); if ($item->isHit()) { return $item->get(); } $classMetadata = $this->factory->getClassMetadata($class); $this->pool->save($item->set($classMetad...
{@inheritdoc}
entailment
public function visitArray($data, TypeMetadataInterface $type, ContextInterface $context) { if ($data === []) { return $this->visitData('[]', $type, $context); } return parent::visitArray($data, $type, $context); }
{@inheritdoc}
entailment
protected function encode($data) { $resource = fopen('php://temp,', 'w+'); $headers = null; if (!is_array($data)) { $data = [[$data]]; } elseif (!empty($data) && !$this->isIndexedArray($data)) { $data = [$data]; } foreach ($data as $value) { ...
{@inheritdoc}
entailment
public function convert($data, TypeMetadataInterface $type, ContextInterface $context) { return $context->getVisitor()->visitInteger($data, $type, $context); }
{@inheritdoc}
entailment
public function additionalCleanup($additionalFiles) { foreach ($additionalFiles as $path) { $dir_to_remove = $path; $print_message = $this->io->isVeryVerbose(); if (is_dir($dir_to_remove)) { if (static::deleteRecursive($dir_to_remove)) { ...
Remove other files that could be possibly problematic. @param \Composer\Script\Event $event A Event object.
entailment
protected function findPackageKey($package_name) { $package_key = null; // In most cases the package name is already used as the array key. if (isset(static::$packageToCleanup[$package_name])) { $package_key = $package_name; } else { // Handle any mismatch in ...
Find the array key for a given package name with a case-insensitive search. @param string $package_name The package name from composer. This is always already lower case. @return string|null The string key, or NULL if none was found.
entailment
protected function deleteRecursive($path) { if (is_file($path) || is_link($path)) { return unlink($path); } $success = true; $dir = dir($path); while (($entry = $dir->read()) !== false) { if ($entry == '.' || $entry == '..') { continue;...
Helper method to remove directories and the files they contain. @param string $path The directory or file to remove. It must exist. @return bool TRUE on success or FALSE on failure.
entailment
protected function loadClass(\ReflectionClass $class) { $definition = parent::loadClass($class); foreach ($this->reader->getClassAnnotations($class) as $annotation) { if ($annotation instanceof ExclusionPolicy) { $definition['exclusion_policy'] = $annotation->policy; ...
{@inheritdoc}
entailment
protected function loadMethod(\ReflectionMethod $method) { $result = $this->loadAnnotations($this->reader->getMethodAnnotations($method)); if (!empty($result)) { return $result; } }
{@inheritdoc}
entailment
private function loadAnnotations(array $annotations) { $definition = []; foreach ($annotations as $annotation) { if ($annotation instanceof Alias) { $definition['alias'] = $annotation->alias; } elseif ($annotation instanceof Type) { $definitio...
@param object[] $annotations @return mixed[]
entailment
protected function doConvert($name) { $item = $this->cache->getItem($name); if ($item->isHit()) { return $item->get(); } $result = $this->strategy->convert($name); $this->cache->save($item->set($result)); return $result; }
{@inheritdoc}
entailment
public function navigate($data, ContextInterface $context, TypeMetadataInterface $type = null) { $type = $type ?: $this->typeGuesser->guess($data); $name = $type->getName(); if ($data === null) { $name = Type::NULL; } return $this->typeRegistry->getType($name, $...
{@inheritdoc}
entailment
public function convert($data, TypeMetadataInterface $type, ContextInterface $context) { return $context->getVisitor()->visitFloat($data, $type, $context); }
{@inheritdoc}
entailment
public function add(string $id): self { if (!isset($this->data[$id])) { $registeredAddon = \BearFramework\Addons::get($id); if ($registeredAddon === null) { throw new \Exception('The addon ' . $id . ' is not registered!'); } $registeredAddonOpt...
Enables an addon. @param string $id The id of the addon. @throws \Exception @return self Returns a reference to itself.
entailment
public function get(string $id): ?\BearFramework\App\Addon { if (isset($this->data[$id])) { return clone($this->data[$id]); } return null; }
Returns the enabled addon or null if not found. @param string $id The id of the addon. @return BearFramework\App\Addon|null The enabled addon or null if not found.
entailment
public function getList() { $list = new \BearFramework\DataList(); foreach ($this->data as $addon) { $list[] = clone($addon); } return $list; }
Returns a list of all enabled addons. @return \BearFramework\DataList|\BearFramework\App\Addon[] An array containing all enabled addons.
entailment
public function navigate($data, ContextInterface $context, TypeMetadataInterface $type = null) { $type = $type ?: $this->typeGuesser->guess($data); $serialization = $context->getDirection() === Direction::SERIALIZATION; if ($serialization) { $this->dispatcher->dispatch( ...
{@inheritdoc}
entailment
public function populate($source, array $propertyNameMap = array(), $onlyMappedProperties = false) { $this->populateInternal($source, $propertyNameMap, $onlyMappedProperties, false); }
Populates this instance, using standard references (as opposed to cloning) when objects are encountered. @param PopulateInterface|array $source A key=>value array or another PopulateInterface instance to use as data @param array $propertyNameMap Optional array of property names supporting mapping (...
entailment
public function populateWithClones($source, array $propertyNameMap = array(), $onlyMappedProperties = false) { $this->populateInternal($source, $propertyNameMap, $onlyMappedProperties, true); }
Populates this instance, cloning any object values that may be encountered. @param PopulateInterface|array $source A key=>value array or another PopulateInterface instance to use as data @param array $propertyNameMap Optional array of property names supporting mapping (see README) @param boolean ...
entailment
private function populateInternal($source, array $propertyNameMap, $onlyMappedProperties, $cloneObjects) { // decide where values come from or throw Exception if not retrievable if ($source instanceof PopulateInterface) { $data = $source->exportGettableProperties($propertyNameMap, $onlyM...
Populate this instance using data from $source, optionally mapping properties from source to this object using $propertyNameMap and if using the property map, only populating those properties whose names were passed in the property map. To selectively populate properties without mapping their names, use a mirror array...
entailment
public function exportGettableProperties(array $propertyNameMap = array(), $onlyMappedProperties = false) { $export = array(); $propertyNameMap = $this->convertPropertyMap($propertyNameMap); // Loop values, skipping mapped properties, use Trait's internal getter to get value. // We ...
Exports properties from this object to a plain array, optionally mapping property names to array indices using a property name map - and optionally only exporting those properties whose names are included in the property name map. To selectively populate properties without mapping their names, use a mirror array as pr...
entailment
private function determinePropertyAccessFunctionName($propertyName, $method) { $methodSuffix = ucfirst($propertyName); $accessMethodNames = array(); foreach ($this->populatableAccessorMethodNamePrefixes[$method] as $methodPrefix) { if (method_exists($this, $methodPrefix . $method...
Determines the function name used for property access through a getter/setter. For a property named `employed`, the following methods are checked: - setEmployed() - getEmployed() If those aren't found and in order to accommodate booleans: - setIsEmployed() - getIsEmployed() - isEmployed() - employed() @param strin...
entailment
private function setPopulatedProperty($propertyName, $value, $cloneObjects) { $method = $this->determinePropertyAccessFunctionName($propertyName, 'set'); if ($value !== null || $this->determineMethodParameterAllowsNull($method)) { if ($cloneObjects && is_object($value)) { ...
Sets a single property via the resolved setter method, throws a Dkd\Populate\Exception if no method could be found and $ignoreFailures was false. @param string $propertyName Name of the property to set on this instance @param mixed $value New value of the property @param boolean $cloneObjects If <code>true</code...
entailment
private function convertPropertyMap(array $propertyNameMap) { $rebuilt = array(); foreach ($propertyNameMap as $origin => $destination) { if (is_integer($origin)) { $origin = $destination; } $rebuilt[$origin] = $destination; } retur...
Converts the input array if necessary: check each property defined in the array to ensure an output of an associative array regardless of the input array structure. The array can be mixed associative and numerically indexed - the output will always be associative; any entries which have numeric indexes will be returned...
entailment
public function smartALookup($hostname, $depth = 0) { $this->debug('SmartALookup for ' . $hostname . ' depth ' . $depth); // avoid recursive lookups if ($depth > 5) { return ''; } // The SmartALookup function will resolve CNAMES using the additional properties i...
@param string $hostname @param int $depth @return string
entailment
public function topMenu() { $topMenus = $this->collectNodes->filter(function ($value, $key) { return 0 == $value['parent_id']; }); $currentTopMenu = $this->currentTopMenu; $topMenus = $topMenus->map(function ($value, $key) use ($currentTopMenu) { if ($curren...
Left sider-bar menu. @return array
entailment
protected function getCurrentTopMenuByUri($currentMenuUri) { $topMenus = $this->collectNodes->filter(function ($value, $key) { return 0 == $value['parent_id']; }); $topMenus->each(function ($item, $key) use ($currentMenuUri, &$currentTopMenu) { $currentUri = array_fir...
@param $currentMenuUri @return mixed
entailment
protected function grid() { return Administrator::grid(function (Grid $grid) { $grid->id('ID')->sortable(); $grid->username(trans('admin.username')); $grid->name(trans('admin.name')); $grid->roles(trans('admin.roles'))->pluck('name')->label(); $gri...
Make a grid builder. @return Grid
entailment
public function form($id=0) { return Administrator::form(function (Form $form) { $form->display('id', 'ID'); $form->text('username', trans('admin.username'))->rules('required'); $form->text('name', trans('admin.name'))->rules('required'); $form->email('ema...
Make a form builder. @return Form
entailment
public function boot() { app('view')->prependNamespace('admin', __DIR__ . '/../resources/views'); // merge configs $this->mergeConfigFrom( __DIR__ . '/../config/backend.php', 'ibrand.backend' ); if ($this->app->runningInConsole()) { $this->publishes(...
Boot the service provider.
entailment
public function retrieveByToken($identifier, $token) { $userModel = $this->createUserModel(); return $userModel->newQuery() ->where($userModel->getKeyName(), $identifier) ->where($userModel->getRememberTokenName(), $token) ->first(); }
Retrieve a user by their unique identifier and "remember me" token. @param mixed $identifier @param string $token @return \Illuminate\Contracts\Auth\Authenticatable|null
entailment
public function retrieveByCredentials(array $credentials) { // First we will add each credential element to the query as a where clause. // Then we can execute the query and, if we found a user, return it in a // Eloquent User "model" that will be utilized by the Guard instances. $qu...
Retrieve a user by the given credentials. @param array $credentials @return \Illuminate\Contracts\Auth\Authenticatable|null
entailment
public function validateCredentials(UserContract $user, array $credentials) { $credentialsValidated = false; // If the user is set AND, either of auth_type 'internal' or with // auth_type unset or null, then validate against the stored // password hash. Otherwise if the LDAP authent...
Validate a user against the given credentials. @param \Illuminate\Contracts\Auth\Authenticatable $user @param array $credentials @return bool
entailment
private function createUserFromLDAP($userName) { $user = null; $ldapUser = $this->getLDAPUser($userName); // If we found the user in LDAP if (true == $ldapUser ) { $firstName = $ldapUser->getFirstAttribute(Settings::get('eloquent-ldap.first_name_field')); $la...
Creates a local user from the information gained from the LDAP/AD server. @param $userName The name of the user to create.
entailment
private function GetLDAPConnectionOptions() { if (!isset($this->ldapConOp) || is_null($this->ldapConOp)) { // Build basic LDAP connection configuration. $this->ldapConOp = [ "account_suffix" => Settings::get('eloquent-ldap.account_suffix'), "base_...
Builds the LDAP connection options from the configuration files. @return array
entailment
private function GetArrayValueOrDefault($array, $key, $default = null) { $value = $default; try { $value = $array[$key]; if (null === $value) { $value = $default; } } catch( Exception $ex) { $value = $default; } ...
Returns the value of a key in an array, or if not found, returns the default provided. @param $array The array to return the value from. @param $key The key to lookup. @param null $default The default value to return if the key does not exist. @return The value requested or the default...
entailment
private function GetArrayIndexedValueOrDefault($array, $key, $index, $default = null) { $value = $default; try { $value = $this->GetArrayValueOrDefault($array, $key, $default); if ( (isset($value)) && ($value !== $default) ) { $value = $value[$index]; ...
Returns the value of a key at an index in a multi-dimensional array, or if not found, returns the default provided. @param $array The array to return the value from. @param $key The key to lookup. @param $index The index of the value to return. @param null $default The default value to retur...
entailment
private function getLDAPUser($username) { $adldap = false; $adUser = false; try { $ldapQuery = Settings::get('eloquent-ldap.user_filter'); if (strpos($ldapQuery, self::USER_TOKEN)) { $ldapQuery = str_replace(self::USER_TOKEN, $username, $ldapQuery); ...
Queries the LDAP/AD server for a user. @param $userName The name of the user to get information for. @return Adldap User The user.
entailment