sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null) { if (empty($name)) { throw new \InvalidArgumentException('An option name cannot be empty.'); } if (null === $mode) { $mode = self::VALUE_NONE; } elseif (!is_...
Adds a new command option. @param string $name The option name @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts @param int $mode The option mode: One of the VALUE_* constants @param string $description A descri...
entailment
public function callInitialize() { foreach ($this->pluginCollection as $plugin) { $subscriber = new EventSubscriber(); $plugin->initialize($subscriber); $this->eventSubscriberPlugins[] = [$plugin, $subscriber]; $this->addListeners($plugin, $subscriber); ...
Invokes initialize method for each plugin registered.
entailment
public function tearDown() { foreach ($this->eventSubscriberPlugins as list($plugin, $eventSubscriber)) { $this->removeListeners($plugin, $eventSubscriber); } }
Releases resources like event listeners.
entailment
protected function execute(InputInterface $input, OutputInterface $output) { $io = new ConsoleIO($input, $output); $options = [ 'no-dev' => !$input->getOption('dev'), 'no-scripts' => !$input->getOption('no-scripts'), ]; $this->initialMessage($io); $pa...
{@inheritdoc}
entailment
protected function execute(InputInterface $input, OutputInterface $output) { $io = new ConsoleIO($input, $output); $packageManager = $this->getPackageManager($input->getArgument('path'), $io); $generator = new ThemeGenerator($packageManager); $generator->setSkeletonDirs([$this->getSk...
{@inheritdoc}
entailment
protected function startingMessage(ConsoleIO $io, $packageName, $siteDir) { $io->newLine(); $io->write(sprintf( '<comment>Installing theme: "%s" in "%s" folder</comment>', $packageName, $siteDir )); $io->newLine(); }
Writes the staring messages. @param ConsoleIO $io Spress IO @param string $template The template
entailment
protected function execute(InputInterface $input, OutputInterface $output) { $io = new ConsoleIO($input, $output); $pmOptions = [ 'dry-run' => $input->getOption('dry-run'), 'prefer-source' => $input->getOption('prefer-source'), 'no-dev' => !$input->getOption('dev'...
{@inheritdoc}
entailment
public function generateItems(ItemInterface $templateItem, array $collections) { $result = []; $options = $this->getAttributesResolver($templateItem); if ($options['max_page'] < 1) { throw new AttributeValueException('Items per page value must be great than 0.', 'max_page', $te...
{@inheritdoc} @throws Yosymfony\Spress\Core\ContentManager\Exception\AttributeValueException if bad attribute value
entailment
public function get($section, $key, $default = null) { $this->checksValidTypes($default); if (isset($this->metadata[$section]) === true && array_key_exists($key, $this->metadata[$section])) { return $this->metadata[$section][$key]; } return $default; }
{@inheritdoc}
entailment
public function set($section, $key, $value) { $this->checksValidTypes($value); if (isset($this->metadata[$section]) === false) { $this->metadata[$section] = []; } $this->metadata[$section][$key] = $value; }
{@inheritdoc}
entailment
public function remove($section, $key = null) { if ($key === null) { $this->metadata[$section] = []; } if (isset($this->metadata[$section]) === true) { unset($this->metadata[$section][$key]); } if (count($this->metadata[$section]) === 0) { ...
{@inheritdoc}
entailment
public function buildFromConfigArray(array $config) { $dsm = new DataSourceManager(); foreach ($config as $dataSourceName => $data) { if (false === isset($data['class'])) { throw new \RuntimeException(sprintf('Expected param "class" at the configuration of the data sourc...
Build a data source manager with data sources loaded from config array. Config array structure: .Array ( [data_source_name_1] => Array ( [class] => Yosymfony\Spress\Core\DataSource\Filesystem\FilesystemDataSource [arguments] => Array ( [source_root] => %site_dir%/src ) ) [data_source_name_2] => Array ( ) ) @param a...
entailment
protected function resolveArgumentsParameters(array $arguments) { foreach ($arguments as $argument => &$value) { if (is_string($value) === false || preg_match('/%[\S_\-]+%/', $value, $matches) === false) { continue; } $name = $matches[0]; if ...
Resolve parameters in arguments. @param array $arguments @return array
entailment
public function add($key, $value) { if ($this->has($key) === false) { $this->set($key, $value); } return $this->array; }
Adds an element using "dot" notation if doesn't exists. You can to escape a dot in a key surrendering with brackets: "[.]". @param $key @param $value @return array
entailment
public function get($key, $default = null) { $array = $this->array; $unescapedKey = $this->unescapeDotKey($key); if (isset($array[$unescapedKey])) { return $array[$unescapedKey]; } foreach (explode('.', $this->escapedDotKeyToUnderscore($key)) as $segment) { ...
Gets a value from a deeply nested array using "dot" notation. You can to escape a dot in a key surrendering with brackets: "[.]". e.g: $a->get('site.data') or $a->get('site.pages.index[.]html') @param string $key @param mixed $default @return mixed
entailment
public function has($key) { $array = $this->array; if (empty($array) || is_null($key)) { return false; } if (array_key_exists($this->unescapeDotKey($key), $array)) { return true; } foreach (explode('.', $this->escapedDotKeyToUnderscore($key)...
Checks if an item exists in using "dot" notation. You can to escape a dot in a key surrendering with brackets: "[.]". @param string $key @return bool
entailment
public function paginate($maxPerPage, $initialPage = 1, $key = null) { $result = []; $page = $initialPage; $array = $this->array; if ($maxPerPage <= 0) { return $result; } if (is_null($key) === false) { $array = $this->get($key); } ...
Paginates the array. @param int $maxPerPage Max items per page. If this value is minor than 1 the result will be an empty array @param int $initialPage Initial page. Page 1 by default @param string $key Element to paginate using "dot" notation @return array A list of pages with an array of elements ass...
entailment
public function remove($key) { $array = &$this->array; if (is_null($key)) { return $array; } $keys = explode('.', $this->escapedDotKeyToUnderscore($key)); while (count($keys) > 1) { $key = $this->underscoreDotKeyToDot(array_shift($keys)); ...
Removes an item using "dot" notation. @param string $key @return array
entailment
public function sort($key = null, callable $callback = null) { $elements = is_null($key) === true ? $this->array : $this->get($key); $sortCallback = is_null($callback) === false ? $callback : function ($element1, $element2) { if ($element1 == $element2) { return 0; ...
Sorts the array (ascendant by default). @param string $key Element to sort using "dot" notation. You can to escape a dot in a key surrendering with brackets: "[.]" @param callable $callback Callback should be a function with the following signature: ```php function($element1, $element2) { // returns -1, 0 or 1...
entailment
public function sortBy(callable $callback, $key = null, $options = SORT_REGULAR, $isDescending = false) { $elements = []; $sourceElements = is_null($key) === true ? $this->array : $this->get($key); foreach ($sourceElements as $key => $value) { $elements[$key] = $callback($key, $...
Sort the array sing the given callback. @param callable $callback Callback should be a function with the following signature: ```php function($key, $value) { // return $processedValue; } ``` @param string $key Element to sort using "dot" notation. You can to escape a dot in a key surrendering with brackets: ...
entailment
public function where(callable $filter) { $filtered = []; foreach ($this->array as $key => $value) { if ($filter($key, $value) === true) { $filtered[$key] = $value; } } return $filtered; }
Filter using the given callback function. @param callable $filter The filter function should be a function with the following signature: ```php function($key, $value) { // returns true if the value is matching your criteria. } ``` @return array
entailment
public function toAscii($removeUnsupported = true) { $str = $this->str; foreach ($this->getChars() as $key => $value) { $str = str_replace($value, $key, $str); } if ($removeUnsupported) { $str = preg_replace('/[^\x20-\x7E]/u', '', $str); } ret...
Transliterate a UTF-8 value to ASCII. @param bool $removeUnsupported Whether or not to remove the unsupported characters @return string
entailment
public function slug($separator = '-') { $str = $this->toAscii(); $flip = $separator == '-' ? '_' : '-'; $str = str_replace('.', $separator, $str); $str = preg_replace('!['.preg_quote($flip).']+!u', $separator, $str); $str = preg_replace('![^'.preg_quote($separator).'\pL\pN\...
Generate a URL friendly "slug". @param string $separator @return string
entailment
public function deletePrefix($prefix) { if ($this->startWith($prefix) === true) { return substr($this->str, strlen($prefix)); } return $this->str; }
Deletes a prefix of the string. @param string $prefix The prefix @return string The string without prefix
entailment
public function deleteSufix($sufix) { if ($this->endWith($sufix) === true) { return substr($this->str, 0, -strlen($sufix)); } return $this->str; }
Deletes a sufix of the string. @param string $sufix The sufix @return string The string without sufix
entailment
protected function getChars() { if (isset($this->chars) === true) { return $this->chars; } $this->chars = [ 'a' => [ 'à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ä', 'ā', 'ą', ...
Gets the conversion table. @return array
entailment
public function getCollectionForItem(ItemInterface $item) { foreach ($this->colectionItemCollection as $name => $collection) { $itemPath = $item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE).'/'; $collectionPath = $collection->getPath().'/'; if (strpos($itemPath, $coll...
Collection matching of a item. @return \Yosymfony\Spress\Core\ContentManager\Collection\CollectionInterface
entailment
public function add($name, ItemInterface $item) { if (isset($this->relationships[$name]) === false) { $this->relationships[$name] = []; } unset($this->relationships[$name][$item->getId()]); $this->relationships[$name][$item->getId()] = $item; }
Adds a relationship. @param string $name The relationship name @param Yosymfony\Spress\Core\DataSource\ItemInterface $item An item
entailment
public function remove($name, ItemInterface $item) { unset($this->relationships[$name][$item->getId()]); if (count($this->relationships[$name]) === 0) { unset($this->relationships[$name]); } }
Removes a relationship from the collection. @param string $name The relationship name
entailment
public function addItem(ItemInterface $item) { if ($this->hasItem($item->getId()) === true) { throw new \RuntimeException(sprintf('A previous item exists with the same id: "%s".', $item->getId())); } $this->items[$item->getId()] = $item; }
Adds a new item. @param Yosymfony\Spress\Core\DataSource\ItemInterface $item @throws RuntimeException If a previous item exists with the same id
entailment
public function addLayout(ItemInterface $item) { if ($this->hasLayout($item->getId()) === true) { throw new \RuntimeException(sprintf('A previous layout item exists with the same id: "%s".', $item->getId())); } $this->layouts[$item->getId()] = $item; }
Adds a new layout item. @param Yosymfony\Spress\Core\DataSource\ItemInterface $item @throws RuntimeException If a previous layout item exists with the same id
entailment
public function addInclude(ItemInterface $item) { if ($this->hasInclude($item->getId()) === true) { throw new \RuntimeException(sprintf('A previous include item exists with the same id: "%s".', $item->getId())); } $this->includes[$item->getId()] = $item; }
Adds a new include item. @param Yosymfony\Spress\Core\DataSource\ItemInterface $item @throws RuntimeException If a previous include item exists with the same id
entailment
public function up() { Schema::create( 'admin_activations', function ( Blueprint $table ) { $table->increments( 'id' ); $table->integer( 'user_id' )->unsigned(); $table->string( 'code' ); $table->boolean( 'completed' )->default( 0 ); $table...
Run the migrations. @return void
entailment
public function createRedirectResponse(Request $request, $path, $status = 302) { return new RedirectResponse($this->httpUtils->generateUri($request, $path), $status); }
@param Request $request @param string $path @param int $status @return RedirectResponse @throws \LogicException @throws \InvalidArgumentException
entailment
public function createSignedRedirectResponse(Request $request, $path, $status = 302) { return new RedirectResponse($this->httpUtils->generateUri($request, $this->uriSigner->sign($path)), $status); }
@param Request $request @param string $path @param int $status @return RedirectResponse @throws \LogicException @throws \InvalidArgumentException
entailment
public function register() { $this->registerPersistences(); $this->registerUsers(); $this->registerRoles(); $this->registerCheckpoints(); $this->registerReminders(); $this->registerSentinel(); }
{@inheritDoc}
entailment
protected function registerPersistences() { $this->registerSession(); $this->registerCookie(); $this->app->singleton( 'sentinel.persistence', function ( $app ) { return new IlluminatePersistenceRepository( $app['sentinel.session'], $app['s...
Registers the persistences. @return void
entailment
protected function registerUsers() { $this->registerHasher(); $this->app->singleton( 'sentinel.users', function ( $app ) { return new IlluminateUserRepository( $app['sentinel.hasher'], $app['events'], User::class ); ...
Registers the users. @return void
entailment
protected function registerCheckpoints() { $this->registerActivationCheckpoint(); $this->registerThrottleCheckpoint(); $this->app->singleton( 'sentinel.checkpoints', function ( $app ) { return [ $app["sentinel.checkpoint.throttle"], $app[...
Registers the checkpoints. @return void @throws \InvalidArgumentException
entailment
protected function registerThrottling() { $this->app->singleton( 'sentinel.throttling', function ( $app ) { $config = $app['config']->get( 'arbory.auth.throttling' ); $globalInterval = array_get( $config, 'global.interval' ); $globalThresholds = array_get( $confi...
Registers the throttle. @return void
entailment
protected function registerReminders() { $this->app->singleton( 'sentinel.reminders', function ( $app ) { return new IlluminateReminderRepository( $app['sentinel.users'], Reminder::class, $app['config']->get( 'arbory.auth.reminders.expires'...
Registers the reminders. @return void
entailment
protected function garbageCollect() { $config = $this->app['config']->get( 'arbory.auth' ); $this->sweep( $this->app['sentinel.activations'], $config['activations']['lottery'] ); $this->sweep( $this->app['sentinel.reminders'], $config['reminders']['lottery']...
Garbage collect activations and reminders. @return void
entailment
public function handle( $request, Closure $next ) { if( !$this->sentinel->check() ) { return $this->denied( $request ); } return $next( $request ); }
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @return mixed
entailment
public function process(ContainerBuilder $container) { $parameter = $container->getParameter('krtv_single_sign_on_identity_provider.secret_parameter'); $container->getDefinition('krtv_single_sign_on_identity_provider.security.authentication.encoder') ->replaceArgument(0, $container->get...
{@inheritDoc}
entailment
public function process(ContainerBuilder $container) { $container->getDefinition('krtv_single_sign_on_identity_provider.routing.loader') ->replaceArgument(0, $container->getParameter('krtv_single_sign_on_identity_provider.host')) ->replaceArgument(1, $container->getParameter('krtv_si...
{@inheritDoc}
entailment
public function register() { $this->registerCacheRepository(); $this->registerLoader(); $this->app->singleton( 'translator', function ( Application $app ) { $trans = new Translator( $app['translation.loader'], $app->getLocale() ); $trans->setFallback( config(...
Register the service provider. @return void
entailment
protected function registerLoader() { $this->app->singleton('translation.loader', function (Application $app) { $defaultLocale = $app->getLocale(); $cacheTimeout = config('translator.cache.timeout', 60); $laravelFileLoader = new LaravelFileLoader($app['files'], base_path...
Register the translation line loader. @return void
entailment
protected function registerFileLoader() { $app = $this->app; $defaultLocale = config( 'app.locale' ); $languageRepository = $app->make( LanguageRepository::class ); $translationRepository = $app->make( TranslationRepository::class ); $translationsPath = base_path( 'resources/...
Register the translator:load language file loader. @return void
entailment
public function registerCacheFlusher() { $command = new TranslationsCacheFlushCommand( $this->app['translation.cache.repository'], true ); $this->app['command.translator:flush'] = $command; $this->commands( 'command.translator:flush' ); }
Flushes the translation cache @return void
entailment
public function handle( $request, Closure $next ) { $targetModule = $this->resolveTargetModule( $request ); if( !$targetModule ) { throw new \RuntimeException( 'Could not find target module for route controller' ); } if( !$targetModule->isAuthorized() ) ...
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @return mixed
entailment
public function render() { $footer = Html::footer(); foreach( $this->getRows() as $row ) { $footer->append( $row->render() ); } if( $this->type ) { $footer->addClass( $this->type ); } return $footer; }
Get the evaluated contents of the object. @return Element
entailment
public function getDefaultResourceForLocale( $locale ) { $resource = null; if( $this->getValue() && !$this->getValue()->isEmpty() ) { foreach( $this->getValue() as $index => $item ) { if( $item->{$this->getModel()->getLocaleKey()} === $locale ) ...
@see \Arbory\Base\Http\Controllers\Admin\SettingsController::getField @param $locale @return Model|null
entailment
public function render() { $tools = Html::div()->addClass( 'tools' ); foreach( $this->blocks() as $name => $content ) { $tools->append( Html::div( $content->toArray() )->addClass( $name ) ); } return $tools; }
Get the evaluated contents of the object. @return string
entailment
public function up() { Schema::table('nodes', function (Blueprint $table) { $table->unique('id'); $table->unique(['content_type', 'content_id']); $table->index('slug'); $table->index('parent_id'); $table->index('lft'); $table->index('r...
Run the migrations. @return void
entailment
public function down() { Schema::table('nodes', function (Blueprint $table) { $table->dropUnique('nodes_id_unique'); $table->dropUnique('nodes_content_type_content_id_unique'); $table->dropIndex('nodes_slug_index'); $table->dropIndex('nodes_parent_id_index');...
Reverse the migrations. @return void
entailment
public function getConfigTreeBuilder() { $builder = new TreeBuilder(); $builder->root('krtv_single_sign_on_identity_provider') ->children() ->scalarNode('host') ->isRequired() ->validate() ->ifTrue(function(...
Generates the configuration tree builder. @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
entailment
public function register() { $this->app->singleton( SettingRegistry::class, function() { return new SettingRegistry(); } ); $this->app->singleton( 'arbory_settings', function() { return new Settings( $this->app[ SettingRegistry::class ] ); } )...
{@inheritDoc}
entailment
public function boot() { $paths = [ __DIR__ . '/../../config/settings.php', config_path( 'settings.php' ) ]; foreach( $paths as $path ) { if( file_exists( $path ) ) { $this->app[ SettingRegistry::class ]->importFromConf...
{@inheritDoc}
entailment
public function boot() { $this->registerResources(); $this->registerServiceProviders(); $this->registerAliases(); $this->registerModuleRegistry(); $this->registerCommands(); $this->registerRoutesAndMiddlewares(); $this->registerFields(); $this->registe...
Bootstrap the application services. @return void
entailment
private function registerServiceProviders() { $this->app->register( ArboryTranslationServiceProvider::class ); $this->app->register( TranslatableServiceProvider::class ); $this->app->register( ArboryFileServiceProvider::class ); $this->app->register( ArboryAuthServiceProvider::class ...
Register related service providers
entailment
private function registerAliases() { $aliasLoader = AliasLoader::getInstance(); // $aliasLoader->alias( 'TranslationCache', \Waavi\Translation\Facades\TranslationCache::class ); $aliasLoader->alias( 'Activation', \Cartalyst\Sentinel\Laravel\Facades\Activation::class ); $aliasLoader->a...
Register related aliases
entailment
private function registerResources() { $configFilename = __DIR__ . '/../../config/arbory.php'; $this->mergeConfigFrom( $configFilename, 'arbory' ); $this->publishes( [ $configFilename => config_path( 'arbory.php' ) ], 'config' ); $this->publishes( [ ...
Publish configuration file.
entailment
private function registerRoutesAndMiddlewares() { /** * @var Router $router */ $router = $this->app[ 'router' ]; $router->middlewareGroup( 'admin', [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToRespons...
Load admin routes and register middleware
entailment
private function registerCommands() { $commands = [ 'arbory.seed' => SeedCommand::class, 'arbory.install' => InstallCommand::class, 'arbory.generator' => GeneratorCommand::class, 'arbory.generate' => GenerateCommand::class ]; foreach( $command...
Register Arbory commands
entailment
private function registerModuleRegistry() { $this->app->singleton( 'arbory', function () { return new Admin( $this->app['sentinel'], new Menu(), new AssetPipeline() ); } ); $this->app->singleton( Admin::class, f...
Register Arbory module registry
entailment
private function registerFields() { $this->app->singleton( FieldTypeRegistry::class, function ( Application $app ) { $fieldTypeRegistry = new FieldTypeRegistry(); $fieldTypeRegistry->registerByType( 'integer', Hidden::class, 'int' ); $fieldTypeRegistry->registerB...
Register Arbory fields
entailment
private function registerGeneratorStubs() { $this->app->singleton( StubRegistry::class, function( Application $app ) { $stubRegistry = new StubRegistry(); $stubRegistry->registerStubs( $app[ Filesystem::class ], base_path( 'vendor/arbory/arbor...
Register stubs used by generators
entailment
public function process(ContainerBuilder $container) { $services = array(); $activeServices = $container->getParameter('krtv_single_sign_on_identity_provider.services'); foreach ($container->findTaggedServiceIds('sso.service_provider') as $id => $attributes) { $name = $attribut...
{@inheritDoc}
entailment
public function handle($request, Closure $next) { $redirect = Redirect::query(); $redirect->where('from_url', $request->url()); $redirect->orWhere('from_url', 'LIKE', '_' . $request->path() . '_'); $redirect = $redirect->first(['to_url', 'status']); if ($redirect) { ...
Handle an incoming request. @param Request $request @param \Closure $next @return RedirectResponse
entailment
public function handle( $request, Closure $next ) { if( $this->isAllowedIp( $request ) ) { return $next( $request ); } return abort( 403 ); }
Handle an incoming request. @param Request $request @param \Closure $next @return RedirectResponse|null
entailment
public function handle( $request, Closure $next ) { if( $this->sentinel->check() ) { if( $request->ajax() ) { $message = trans( 'arbory.admin_unauthorized', 'Unauthorized' ); return response()->json( [ 'error' => $message ], 401 ); ...
Handle an incoming request. @param Request $request @param \Closure $next @return JsonResponse|RedirectResponse
entailment
public function up() { Schema::create( 'nodes', function ( Blueprint $table ) { $table->uuid( 'id' ); $table->string( 'name' ); $table->string( 'slug' ); $table->uuid( 'parent_id' )->nullable(); $table->integer( 'lft' )->nullable(); ...
Run the migrations. @return void
entailment
public function findBySlug( $uri ) { $parts = explode( '/', trim( $uri, '/' ) ); $node = null; foreach( $parts as $depth => $part ) { $query = $this->newQuery()->where( 'depth', $depth )->where( 'slug', $part ); if( $node instanceof Node ) { ...
* @param $uri @return Node|null
entailment
public function save( array $options = [] ) { if( $this->exists ) { if( count( $this->getDirty() ) > 0 ) { // If $this->exists and dirty, parent::save() has to return true. If not, // an error has occurred. Therefore we shouldn't save the trans...
@param array $options @return bool
entailment
protected function getTranslationOrNew( $locale ) { if( ( $translation = $this->getTranslation( $locale, false ) ) === null ) { $translation = $this->getNewTranslation( $locale ); } return $translation; }
@param string $locale @return \Illuminate\Database\Eloquent\Model|null
entailment
private function getFallbackLocale( $locale = null ) { if( $locale && $this->isLocaleCountryBased( $locale ) ) { return $this->getLanguageFromCountryBasedLocale( $locale ); } return Config::get( 'translatable.fallback_locale' ); }
@param string|null $locale @return string
entailment
public function scopeWithTranslation( Builder $query ) { $query->with( [ 'translations' => function( Relation $query ) { $query->where( $this->getTranslationsTable() . '.' . $this->getLocaleKey(), $this->locale() ); if( $this->isUsingTranslationFallba...
This scope eager loads the translations for the default and the fallback locale only. We can use this as a shortcut to improve performance in our application. @param Builder $query
entailment
public function deleteTranslations( $locales = null ) { if( $locales === null ) { $this->translations()->delete(); } else { $locales = (array)$locales; $this->translations()->whereIn( $this->getLocaleKey(), $locales )->delete(); } ...
Deletes all translations for this model. @param string|array|null $locales The locales to be deleted (array or single string) (e.g., ["en", "de"] would remove these translations).
entailment
public function upload() { $response = parent::upload(); return count($this->errors) > 0 ? $this->errorResponse() : $response; }
Upload files @param void @return string
entailment
public function render() { return Html::div( [ $this->getPreviousPageButton(), $this->getPagesSelect(), $this->getNextPageButton(), ] )->addClass( 'pagination' ); }
Get the evaluated contents of the object. @return string|Element
entailment
public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new RoutingConfigPass()); $container->addCompilerPass(new ServiceProvidersPass()); $container->addCompilerPass(new ResolveSecretPass()); }
{@inheritDoc}
entailment
public static function filter($html, array $config = null, $spec = null) { require_once __DIR__.'/htmLawed/htmLawed.php'; if ($config === null) { $config = self::$defaultConfig; } if (isset($config['spec']) && !$spec) { $spec = $config['spec']; } ...
Filters a string of html with the htmLawed library. @param string $html The text to filter. @param array|null $config Config settings for the array. @param string|array|null $spec A specification to further limit the allowed attribute values in the html. @return string Returns the filtered html. @see http://www.bioinf...
entailment
public static function filterRSS($html) { $config = array( 'anti_link_spam' => ['`.`', ''], 'comment' => 1, 'cdata' => 3, 'css_expression' => 1, 'deny_attribute' => 'on*,style,class', 'elements' => '*-applet-form-input-textarea-iframe-scrip...
Filter a string of html so that it can be put into an rss feed. @param $html The html text to fitlter. @return string Returns the filtered html. @see Htmlawed::filter().
entailment
public function clear() { $this->session->remove($this->getSessionKey()); $this->session->remove($this->getSessionExtraKey()); $this->session->remove($this->getSessionTargetPathKey()); }
Clear services management session variables.
entailment
public function register() { AliasLoader::getInstance()->alias( 'ArboryRouter', ArboryRouter::class ); AliasLoader::getInstance()->alias( 'Admin', Admin::class ); AliasLoader::getInstance()->alias( 'Page', Page::class ); AliasLoader::getInstance()->alias( 'Settings', Settings::class ...
Register the service provider. @return void
entailment
public function createDynamicallyObjects($struct, $keypath_array) { if (!$this->studyType($struct, $problem)) { return $problem; } $path_string = ""; for ($i = 0; $i < count($keypath_array); $i++) { $key = $keypath_array[$i]; $path_string .= $key...
[Create nested obj Dynamically if(key exist || key !exist), by $path_string @param [array|string|\stdClass] $struct1 [Structure] @param [array] $keypath_array [Array with the keys that will be created] @return [array|string|\stdClass] New structure
entailment
private function accessDynamically($path_string, &$array) { $keys = explode('/', substr_replace($path_string, "", -1)); $ref = &$array; foreach ($keys as $key => $value) { $ref = &$ref[$value]; } $ref = array(); }
[This function enables you to dynamically access the value of a structure] @param [string] $path_string [path] @param [array] $array current [array]
entailment
public function walker(&$struct, $callback) { if (!$this->studyType($struct, $problem)) { return $problem; } $this->clockStart(); $replaceWalker = function(&$struct, $callback) use (&$replaceWalker) { if (is_array($struct)) { foreach...
[walk throughout the structure] @param [array|string|\stdClass] $struct [Structure] @param [function] $callback [The function will always be called when walking through the nodes] @return [array|string|\stdClass] Input structure
entailment
public function getdiff($struct1, $struct2, $slashtoobject = false) { if (!$this->studyType($struct1, $problem) || !$this->studyType($struct2, $problem)) { return $problem; } $this->clockStart(); $structpath1_array = array(); $structpath2_array = array(); ...
Returns the difference between two structures @param [array|string|\stdClass] $struct1 [struct1] @param [array|string|\stdClass] $struct2 [struct2] @return [array|string|\stdClass] struct diff
entailment
private function structPathArray($assocarray, &$array, $currentpath) { if (is_array($assocarray)) { foreach ($assocarray as $key => $value) { if (array_key_exists($key, $assocarray)) { $path = $currentpath !== '' ? $currentpath . "/" . $key : sprintf($key); ...
[Returns a array with all the possible paths of the structure -> &$array. There is several ways to do this and i believe it's not the best way, but I chose this way, separately(structPathArray() + structPathArrayDiff()), to be more didactic. In the middle of recursion I could already make comparisons could be faster.] ...
entailment
public function structMerge($struct1, $struct2, $slashtoobject = false) { if (!$this->studyType($struct1, $problem) || !$this->studyType($struct2, $problem)) { return $problem; } $this->clockStart(); $structpath1_array = array(); $structpath2_array = array(); ...
[Join two structures] @param [array|string|\stdClass] $struct1 [Structure] @param [array|string|\stdClass] $struct2 [Structure] @return [array|string|\stdClass] [The union of structures]
entailment
private function pathSlashToStruct($assocarray) { $new_assocarray = []; $this->switchType(); if (is_array($assocarray)) { foreach ($assocarray as $key => $value) { if (strpos($key, '/') !== false) { $aux = explode("/", $key); ...
[Convert the slashs to nested structures] @param [type] $assocarray [Associative array to convert the keys] @return [array] [No slashs on key]
entailment
private function structPathArrayDiff($structpath1_array, $structpath2_array, $slashtoobject) { $deltadiff_array = array( "new" => array(), "removed" => array(), "edited" => array() ); foreach ($structpath1_array as $key1 => $value1) { if ...
[Returns a structure with the news] @param [array] $structpath1_array [Vector paths of structure 1] @param [array] $structpath2_array [Vector paths of structure 2] @param [boolean] $slashtoobject [Simple path with slashs or nested structures] @return [array] [Delta array]
entailment
private function returnTypeConvert($struct) { switch ($this->config["returntype"]) { case 'jsonstring': if (!($this->isJsonString($struct))) { return json_encode($struct); } return $struct; break; cas...
[Returns a converted structure] @param [array|string|\stdClass] $struct [Structure for converting] @return [array|string|\stdClass] [Converted structure]
entailment
private function studyType(&$struct, &$problem) { if ($this->isJsonString($struct)) { $struct = json_decode($struct, true); return true; } else if(is_array($struct)) { return true; } else if(is_object($struct)) { $struct = (array)$struct; ...
[analyzes the structure] @param [array|string|\stdClass] &$struct [Structure] @param [string] &$problem [If there is a problem with the structure , it will be returned] @return [type] [true->Everything is ok, false->Error]
entailment
private function switchType() { $aux = $this->config["returntype"]; $this->config["returntype"] = $this->typetowork; $this->typetowork = $aux; }
[switch the type]
entailment
public function indexAction(string $slugs = '', Request $request): Response { if (preg_match('#/$#', $slugs)) { return $this->redirect($this->generateUrl('orbitale_cms_category', ['slugs' => rtrim($slugs, '/')])); } $slugsArray = preg_split('~/~', $slugs, -1, PREG_SPLIT_NO_EMPTY...
@param string $slugs @param Request $request @return Response
entailment
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); foreach ($config['layouts'] as $name => $layout) { $config['layouts'][$name] = array_merge([ ...
{@inheritdoc}
entailment
public function addChild(Page $page): Page { $this->children->add($page); if ($page->getParent() !== $this) { $page->setParent($this); } return $this; }
@param Page $page @return Page
entailment
public function getTree(string $separator = '/') { $tree = ''; $current = $this; do { $tree = $current->getSlug().$separator.$tree; $current = $current->getParent(); } while ($current); return trim($tree, $separator); }
@param string $separator @return string
entailment