sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function shouldBeIncluded(string $sectionName): bool
{
return (count($this->includeExcluded) > 0 && in_array($sectionName, $this->includeExcluded));
} | @param string $sectionName
@return bool | entailment |
protected function isExcludedByName(string $sectionName): bool
{
return count($this->excludedSections) > 0 && in_array($sectionName, $this->excludedSections);
} | @param string $sectionName
@return bool | entailment |
public function buildSection(string $name, array $definition): SectionInterface
{
$section = new Section($name);
$this->setExcluded($section, $definition);
$this->setPreCommand($section, $definition);
$this->setPostCommand($section, $definition);
return $section;
} | @param string $name
@param array $definition
@return \Spryker\Install\Stage\Section\SectionInterface | entailment |
protected function setExcluded(SectionInterface $section, array $definition)
{
if (isset($definition[static::CONFIG_EXCLUDED]) && $definition[static::CONFIG_EXCLUDED]) {
$section->markAsExcluded();
}
} | @param \Spryker\Install\Stage\Section\SectionInterface $section
@param array $definition
@return void | entailment |
protected function setPreCommand(SectionInterface $section, array $definition)
{
if (isset($definition[static::CONFIG_PRE_COMMAND])) {
$section->setPreCommand($definition[static::CONFIG_PRE_COMMAND]);
}
} | @param \Spryker\Install\Stage\Section\SectionInterface $section
@param array $definition
@return void | entailment |
protected function setPostCommand(SectionInterface $section, array $definition)
{
if (isset($definition[static::CONFIG_POST_COMMAND])) {
$section->setPostCommand($definition[static::CONFIG_POST_COMMAND]);
}
} | @param \Spryker\Install\Stage\Section\SectionInterface $section
@param array $definition
@return void | entailment |
private static function _createBatchHelper(Api\MtBatchSmsCreate &$batch)
{
$fields = [
'from' => $batch->getSender(),
'to' => $batch->getRecipients()
];
if (null != $batch->getDeliveryReport()) {
$fields['delivery_report'] = $batch->getDeliveryReport();
... | Helper that prepares the fields of a batch creates for JSON
serialization.
@param Api\MtBatchSmsCreate $batch the batch to serialize
@return [] associative array for JSON serialization | entailment |
public static function textBatch(Api\MtBatchTextSmsCreate $batch)
{
$fields = Serialize::_createBatchHelper($batch);
$fields['type'] = 'mt_text';
$fields['body'] = $batch->getBody();
if (!empty($batch->getParameters())) {
$fields['parameters'] = $batch->getParameters();... | Serializes the given text batch into JSON.
@param Api\MtBatchTextSmsCreate $batch the batch to serialize
@return string JSON formatted string | entailment |
public static function binaryBatch(Api\MtBatchBinarySmsCreate $batch)
{
$fields = Serialize::_createBatchHelper($batch);
$fields['type'] = 'mt_binary';
$fields['body'] = base64_encode($batch->getBody());
$fields['udh'] = bin2hex($batch->getUdh());
return Serialize::_toJson(... | Serializes the given binary batch into JSON.
@param Api\MtBatchBinarySmsCreate $batch the batch to serialize
@return string JSON formatted string | entailment |
private static function _batchUpdateHelper(Api\MtBatchSmsUpdate $batch)
{
$fields = [];
if (!empty($batch->getRecipientInsertions())) {
$fields['to_add'] = $batch->getRecipientInsertions();
}
if (!empty($batch->getRecipientRemovals())) {
$fields['to_remove']... | Helper that prepares the given batch for serialization
@param Api\MtBatchSmsUpdate $batch the batch to serialize
@return [] associative array suitable for JSON serialization | entailment |
public static function textBatchUpdate(Api\MtBatchTextSmsUpdate $batch)
{
$fields = Serialize::_batchUpdateHelper($batch);
$fields['type'] = 'mt_text';
if (null != $batch->getBody()) {
$fields['body'] = $batch->getBody();
}
if (null != $batch->getParameters()) ... | Serializes the given text batch update into JSON.
@param Api\MtBatchTextSmsUpdate $batch the batch update to serialize
@return string JSON formatted string | entailment |
public static function binaryBatchUpdate(Api\MtBatchBinarySmsUpdate $batch)
{
$fields = Serialize::_batchUpdateHelper($batch);
$fields['type'] = 'mt_binary';
if (null != $batch->getBody()) {
$fields['body'] = base64_encode($batch->getBody());
}
if (null != $bat... | Serializes the given binary batch update into JSON.
@param Api\MtBatchBinarySmsUpdate $batch the batch update to serialize
@return string JSON formatted string | entailment |
public static function _groupAutoUpdateHelper(
Api\GroupAutoUpdate $autoUpdate
) {
$fields = [ 'to' => $autoUpdate->getRecipient() ];
if (null != $autoUpdate->getAddFirstWord()) {
$fields['add']['first_word'] = $autoUpdate->getAddFirstWord();
}
if (null != $auto... | Helper that prepares the given group auto update for JSON
serialization.
@param Api\GroupAutoUpdate $autoUpdate the auto update to serialize
@return [] associative array suitable for JSON serialization | entailment |
public static function group(Api\GroupCreate $group)
{
$fields = [];
if ($group->getName() != null) {
$fields['name'] = $group->getName();
}
if (!empty($group->getMembers())) {
$fields['members'] = $group->getMembers();
}
if (!empty($group->... | Serializes the given group create object to JSON.
@param Api\GroupCreate $group the group to serialize
@return string a JSON string | entailment |
public static function groupUpdate(Api\GroupUpdate $groupUpdate)
{
$fields = [];
if (null != $groupUpdate->getName()) {
$fields['name'] = $groupUpdate->getName() === Api\Reset::reset()
? null
: $groupUpdate->getName();
}
... | Serializes the given group update object to JSON.
@param Api\GroupUpdate $groupUpdate the group update to serialize
@return string a JSON string | entailment |
protected function addActivate(Builder $builder): void
{
$builder->macro('activate', function (Builder $builder) {
$builder->withNotActivated();
return $builder->update(['is_active' => 1]);
});
} | Add the `activate` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addUndoActivate(Builder $builder): void
{
$builder->macro('undoActivate', function (Builder $builder) {
return $builder->update(['is_active' => 0]);
});
} | Add the `undoActivate` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addWithNotActivated(Builder $builder): void
{
$builder->macro('withNotActivated', function (Builder $builder) {
return $builder->withoutGlobalScope($this);
});
} | Add the `withNotActivated` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addWithoutNotActivated(Builder $builder): void
{
$builder->macro('withoutNotActivated', function (Builder $builder) {
return $builder->withoutGlobalScope($this)->where('is_active', 1);
});
} | Add the `withoutNotActivated` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addOnlyNotActivated(Builder $builder): void
{
$builder->macro('onlyNotActivated', function (Builder $builder) {
return $builder->withoutGlobalScope($this)->where('is_active', 0);
});
} | Add the `onlyNotActivated` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
public function run(CommandInterface $command, ConfigurationInterface $configuration)
{
if (!$this->shouldBeExecuted($command, $configuration)) {
return;
}
$this->environmentHelper->putEnvs($command->getEnv());
$this->runPreCommand($command, $configuration);
$th... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param \Spryker\Install\Configuration\ConfigurationInterface $configuration
@throws \Spryker\Install\Exception\InstallException
@return void | entailment |
protected function runPreCommand(CommandInterface $command, ConfigurationInterface $configuration)
{
if ($command->hasPreCommand()) {
$this->run($configuration->findCommand($command->getPreCommand()), $configuration);
}
} | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param \Spryker\Install\Configuration\ConfigurationInterface $configuration
@return void | entailment |
protected function runCommand(CommandInterface $command, ConfigurationInterface $configuration)
{
$executable = $this->executableFactory->createExecutableFromCommand($command, $configuration);
if (!$command->isStoreAware()) {
$this->executeExecutable($executable, $command, $configuratio... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param \Spryker\Install\Configuration\ConfigurationInterface $configuration
@return void | entailment |
protected function getExecutableStoresForCommand(CommandInterface $command, ConfigurationInterface $configuration): array
{
if (!$command->hasStores()) {
return $configuration->getExecutableStores();
}
return array_intersect($configuration->getExecutableStores(), $command->getSt... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param \Spryker\Install\Configuration\ConfigurationInterface $configuration
@return string[] | entailment |
protected function runPostCommand(CommandInterface $command, ConfigurationInterface $configuration)
{
if ($command->hasPostCommand()) {
$this->run($configuration->findCommand($command->getPostCommand()), $configuration);
}
} | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param \Spryker\Install\Configuration\ConfigurationInterface $configuration
@return void | entailment |
protected function shouldBeExecuted(CommandInterface $command, ConfigurationInterface $configuration): bool
{
if ($configuration->isDryRun()) {
$configuration->getOutput()->dryRunCommand($command);
return false;
}
if ($command->isExcluded() || $this->hasConditionAnd... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param \Spryker\Install\Configuration\ConfigurationInterface $configuration
@return bool | entailment |
protected function hasConditionAndConditionNotMatched(CommandInterface $command): bool
{
if (!$this->isConditionalCommand($command) || $this->conditionMatched($command)) {
return false;
}
return true;
} | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@return bool | entailment |
protected function conditionMatched(CommandInterface $command): bool
{
$matchedConditions = true;
foreach ($command->getConditions() as $condition) {
if (!$condition->match($this->commandExitCodes)) {
$matchedConditions = false;
}
}
return $ma... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@return bool | entailment |
protected function executeExecutable(
ExecutableInterface $executable,
CommandInterface $command,
ConfigurationInterface $configuration,
?string $store = null
) {
$configuration->getOutput()->startCommand($command, $store);
$exitCode = $executable->execute($configura... | @param \Spryker\Install\Executable\ExecutableInterface $executable
@param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param \Spryker\Install\Configuration\ConfigurationInterface $configuration
@param string|null $store
@return void | entailment |
public function getHeaders(bool $implode = false, bool $ucwords = false): array
{
if ($ucwords && $implode) {
$headers = [];
foreach ($this->headers as $key => $val) {
$key = ucwords($key, '-');
$headers[$key] = implode(', ', $val);
}
... | get all headers
@param bool $implode
@param bool $ucwords
@return array | entailment |
public static function getResponseBodySummary(Response $response): string
{
$body = $response->getBody();
$size = $body->getSize();
if ($size === 0) {
return '';
}
$summary = $body->read(120);
$body->rewind();
if ($size > 120) {
$summar... | Get a short summary of the response
Will return `null` if the response is not printable.
@param Response $response
@return string | entailment |
public function startInstall(StageInterface $stage)
{
$this->timer->start($stage);
$message = sprintf('Install <fg=green>%s</> environment', $stage->getName());
$messageLengthWithoutDecoration = Helper::strlenWithoutDecoration($this->output->getFormatter(), $message);
$message = $mes... | @param \Spryker\Install\Stage\StageInterface $stage
@return void | entailment |
public function endInstall(StageInterface $stage)
{
$message = sprintf('Install <fg=green>%s</> finished in <fg=green>%ss</>', $stage->getName(), $this->timer->end($stage));
$this->writeln($message);
} | @param \Spryker\Install\Stage\StageInterface $stage
@return void | entailment |
public function startSection(SectionInterface $section)
{
$this->timer->start($section);
$message = sprintf('<bg=green;options=bold> Section %s</>', $section->getName());
$messageLengthWithoutDecoration = Helper::strlenWithoutDecoration($this->output->getFormatter(), $message);
$mess... | @param \Spryker\Install\Stage\Section\SectionInterface $section
@return void | entailment |
public function endSection(SectionInterface $section)
{
$this->newLine();
if ($this->output->isVerbose()) {
$message = sprintf('Section <fg=green>%s</> finished in <fg=green>%ss</>', $section->getName(), $this->timer->end($section));
$this->writeln($message);
$th... | @param \Spryker\Install\Stage\Section\SectionInterface $section
@return void | entailment |
public function startCommand(CommandInterface $command, $store = null)
{
$this->timer->start($command);
$message = $this->getStartCommandMessage($command, $store);
if ($this->output->getVerbosity() === static::VERBOSITY_NORMAL) {
$message .= sprintf(' <fg=magenta>(In progress...)... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param string|null $store
@return void | entailment |
protected function getStartCommandMessage(CommandInterface $command, $store = null)
{
$commandInfo = sprintf('Command <fg=green>%s</>', $command->getName());
$storeInfo = ($store) ? sprintf(' for <info>%s</info> store', $store) : '';
$executedInfo = sprintf(' <fg=yellow>[%s]</>', $command->... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param string|null $store
@return string | entailment |
public function endCommand(CommandInterface $command, $exitCode, $store = null)
{
if ($this->output->isVeryVerbose()) {
$this->newLine();
}
if ($this->output->isVerbose()) {
$this->writeln($this->getVerboseCommandEndMessage($command, $exitCode));
$this->n... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param int $exitCode
@param string|null $store
@return void | entailment |
protected function endCommandOutputIfNormalOutput(CommandInterface $command, $store = null)
{
if ($this->output->getVerbosity() === static::VERBOSITY_NORMAL) {
$message = $this->getStartCommandMessage($command, $store);
$message .= sprintf(' <fg=green>(%ss)</>', $this->timer->end($co... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param string|null $store
@return void | entailment |
protected function getVerboseCommandEndMessage(CommandInterface $command, $exitCode)
{
return sprintf(
'<fg=green>//</> Command <fg=green>%s</> finished in <fg=green>%ss</>, exit code <fg=%s>%s</>',
$command->getName(),
$this->timer->end($command),
($exitCode ... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@param int $exitCode
@return string | entailment |
public function dryRunCommand(CommandInterface $command)
{
$this->newLine();
$this->write(' // Dry-run: ' . $command->getName());
$this->newLine(3);
} | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@return void | entailment |
public function innerCommand($output)
{
if ($this->output->isVeryVerbose()) {
$this->write($output);
}
if (!$this->output->isVeryVerbose()) {
$this->outputBuffer[] = $output;
}
} | @param string $output
@return void | entailment |
public function write($messages, $options = 0)
{
$this->log($messages);
$this->output->write($messages, false, $options);
} | @param array|string $messages
@param int $options
@return void | entailment |
protected function writeln($messages, $options = 0)
{
$this->log($messages);
$this->output->writeln($messages, $options);
} | @param array|string $messages
@param int $options
@return void | entailment |
protected function log($message): void
{
if ($this->logger !== null) {
$this->logger->log($message);
}
} | @param string|array $message
@return void | entailment |
public static function isDefaultPort(UriInterface $uri): bool
{
return $uri->getPort() === null
|| (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]);
} | Whether the URI has the default port of the current scheme.
`Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
independently of the implementation.
@param UriInterface $uri
@return bool | entailment |
public static function resolve($base, $rel): ?UriInterface
{
if ($base && $rel) {
if (!($base instanceof UriInterface)) {
$base = new self($base);
}
if (!($rel instanceof UriInterface)) {
$rel = new self($rel);
}
ret... | Converts the relative URI into a new URI that is resolved against the base URI.
@param string|UriInterface $base Base URI
@param string|UriInterface $rel Relative URI
@return UriInterface
@see UriResolver::resolve | entailment |
public static function withoutQueryValue(UriInterface $uri, $key): UriInterface
{
$current = $uri->getQuery();
if ($current === '') {
return $uri;
}
$decodedKey = rawurldecode($key);
$result = array_filter(explode('&', $current), function ($part) use ($decodedKey... | Creates a new URI with a specific query string value removed.
Any existing query string values that exactly match the provided key are
removed.
@param UriInterface $uri URI to use as a base.
@param string $key Query string key to remove.
@return UriInterface | entailment |
public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface
{
$current = $uri->getQuery();
if ($current === '') {
$result = [];
} else {
$decodedKey = rawurldecode($key);
$result = array_filter(explode('&', $current), function ($p... | Creates a new URI with a specific query string value.
Any existing query string values that exactly match the provided key are
removed and replaced with the given key value pair.
A value of null will set the query string key without a value, e.g. "key"
instead of "key=value".
@param UriInterface $uri URI to use as a... | entailment |
public static function fromParts(array $parts): UriInterface
{
$uri = new self();
$uri->applyParts($parts);
$uri->validateState();
return $uri;
} | Creates a URI from a hash of `parse_url` components.
@param array $parts
@return UriInterface
@link http://php.net/manual/en/function.parse-url.php
@throws TypeError If the components do not form a valid URI. | entailment |
private function filterHost(string $host): string
{
if ($host && $host !== self::HTTP_DEFAULT_HOST && strpos($host, '.') === false) {
throw new InvalidArgumentException("Host '{$host}' is illegal!");
}
return strtolower($host);
} | @param string $host
@return string
@throws TypeError If the host is invalid. | entailment |
public function createCondition(array $condition): ConditionInterface
{
foreach ($this->conditionNameToConditionClassMap as $conditionName => $conditionClass) {
if (isset($condition[$conditionName])) {
return new $conditionClass($condition['command'], $condition[$conditionName]);... | @param array $condition
@throws \Spryker\Install\Stage\Section\Command\Condition\Exception\ConditionNotFoundException
@return \Spryker\Install\Stage\Section\Command\Condition\ConditionInterface | entailment |
public function apply(Builder $builder, Model $model): void
{
if (method_exists($model, 'shouldApplyEndedAtScope') && $model->shouldApplyEndedAtScope()) {
$builder->whereNull('ended_at');
}
} | Apply the scope to a given Eloquent query builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@param \Illuminate\Database\Eloquent\Model $model
@return void | entailment |
protected function addUndoEnd(Builder $builder): void
{
$builder->macro('undoEnd', function (Builder $builder) {
$builder->withEnded();
return $builder->update(['ended_at' => null]);
});
} | Add the `undoEnd` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addEnd(Builder $builder): void
{
$builder->macro('end', function (Builder $builder) {
return $builder->update(['ended_at' => Date::now()]);
});
} | Add the `end` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addWithoutEnded(Builder $builder): void
{
$builder->macro('withoutEnded', function (Builder $builder) {
return $builder->withoutGlobalScope($this)->whereNull('ended_at');
});
} | Add the `withoutEnded` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addOnlyEnded(Builder $builder): void
{
$builder->macro('onlyEnded', function (Builder $builder) {
return $builder->withoutGlobalScope($this)->whereNotNull('ended_at');
});
} | Add the `onlyEnded` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $this->createOutput($input, $output);
$this->getFacade()->runInstall(
$this->getCommandLineArgumentContainer(),
$this->getCommandLineOptionContainer(),... | @param \Symfony\Component\Console\Input\InputInterface $input
@param \Symfony\Component\Console\Output\OutputInterface $output
@return int|null | entailment |
protected function createOutput(InputInterface $input, OutputInterface $output): StyleInterface
{
$shouldLog = $input->getOption(static::OPTION_LOG);
return new SprykerStyle(
$input,
$output,
$this->getFactory()->createTimer(),
($shouldLog) ? $this->g... | @param \Symfony\Component\Console\Input\InputInterface $input
@param \Symfony\Component\Console\Output\OutputInterface $output
@return \Spryker\Style\StyleInterface | entailment |
protected function getCommandLineArgumentContainer(): CommandLineArgumentContainer
{
$store = $this->input->getArgument(self::ARGUMENT_STORE);
if ($store !== null && !is_string($store)) {
throw new InstallException(
sprintf(
'Value of `%s` argument sh... | @throws \Spryker\Install\Exception\InstallException
@return \Spryker\Install\CommandLine\CommandLineArgumentContainer | entailment |
protected function getCommandLineOptionContainer(): CommandLineOptionContainer
{
$recipeOption = $this->input->getOption(self::OPTION_RECIPE);
if (!is_string($recipeOption)) {
throw new InstallException(
sprintf(
'Value of `%s` option should return `s... | @throws \Spryker\Install\Exception\InstallException
@return \Spryker\Install\CommandLine\CommandLineOptionContainer | entailment |
protected function getOptionAndComment($optionKey, $commentPattern): array
{
$option = (array)$this->input->getOption($optionKey);
if (count($option) > 0) {
$this->output->note(sprintf($commentPattern, implode(', ', $option)));
}
return $option;
} | @param string $optionKey
@param string $commentPattern
@return array | entailment |
public function addCommand(CommandInterface $command): SectionInterface
{
if (isset($this->commands[$command->getName()])) {
throw new CommandExistsException(sprintf('Command with name "%s" already exists.', $command->getName()));
}
$this->commands[$command->getName()] = $command... | @param \Spryker\Install\Stage\Section\Command\CommandInterface $command
@throws \Spryker\Install\Stage\Section\Command\Exception\CommandExistsException
@return \Spryker\Install\Stage\Section\SectionInterface | entailment |
public function getCommand(string $commandName): CommandInterface
{
if (!isset($this->commands[$commandName])) {
throw new CommandNotFoundException(sprintf('Command "%s" not found in "%s" section', $commandName, $this->getName()));
}
return $this->commands[$commandName];
} | @param string $commandName
@throws \Spryker\Install\Stage\Section\Command\Exception\CommandNotFoundException
@return \Spryker\Install\Stage\Section\Command\CommandInterface | entailment |
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
{
$classMetadata = $eventArgs->getClassMetadata();
$reflClass = $classMetadata->reflClass;
if (!$reflClass) {
return;
}
if ($reflClass->implementsInterface('Prezent\Doctrine\Translatable\Tr... | Add mapping to translatable entities
@param LoadClassMetadataEventArgs $eventArgs
@return void | entailment |
private function mapTranslatable(ClassMetadata $mapping)
{
$metadata = $this->getTranslatableMetadata($mapping->name);
if ($metadata->targetEntity
&& $metadata->translations
&& !$mapping->hasAssociation($metadata->translations->name)
) {
$targetMetadata =... | Add mapping data to a translatable entity
@param ClassMetadata $mapping
@return void | entailment |
private function mapTranslation(ClassMetadata $mapping)
{
$metadata = $this->getTranslatableMetadata($mapping->name);
// Map translatable relation
if ($metadata->targetEntity
&& $metadata->translatable
&& !$mapping->hasAssociation($metadata->translatable->name)
... | Add mapping data to a translation entity
@param ClassMetadata $mapping
@return void | entailment |
public function getTranslatableMetadata($className)
{
if (array_key_exists($className, $this->cache)) {
return $this->cache[$className];
}
if ($metadata = $this->metadataFactory->getMetadataForClass($className)) {
if (!$metadata->reflection->isAbstract()) {
... | Get translatable metadata
@param string $className
@return TranslatableMetadata|TranslationMetadata | entailment |
private function hasUniqueConstraint(ClassMetadata $mapping, array $columns)
{
if (!array_diff($mapping->getIdentifierColumnNames(), $columns)) {
return true;
}
if (!isset($mapping->table['uniqueConstraints'])) {
return false;
}
foreach ($mapping->ta... | Check if an unique constraint has been defined
@param ClassMetadata $mapping
@param array $columns
@return bool | entailment |
public function postLoad(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
$metadata = $this->getTranslatableMetadata(get_class($entity));
if ($metadata instanceof TranslatableMetadata) {
if ($metadata->fallbackLocale) {
$metadata->fallbackLocale->setValu... | Load translations
@param LifecycleEventArgs $args
@return void | entailment |
private function readMapping($className)
{
$file = $this->getMappingFile($className);
return $file ? $this->parse($file) : null;
} | Reads the configuration for the given classname.
@param string $className
@return mixed|null | entailment |
public static function parseHeader(string $raw_header): array
{
static $whole_fields = [
'date' => true,
'user-agent' => true,
];
/**
* 生成供于遍历的的header数组 ['row','row','row']
*/
// Pretend CRLF = LF for compatibility (RFC 2616, section 19.3)
... | 解析单个header
@param string $raw_header
@return array | entailment |
public static function parseHeaders(string $raw_header): array
{
$raw_header = explode("\r\n\r\n", $raw_header);
if (count($raw_header) > 1) {
$headers = [];
foreach ($raw_header as $header) {
$headers[] = self::parseHeader($header);
}
... | 解析header,传入多个header时返回[{header},{header},{header}]
@param string $raw_header
@return array | entailment |
protected function addAccept(Builder $builder): void
{
$builder->macro('accept', function (Builder $builder) {
$builder->withNotAccepted();
return $builder->update(['accepted_at' => Date::now()]);
});
} | Add the `accept` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addUndoAccept(Builder $builder): void
{
$builder->macro('undoAccept', function (Builder $builder) {
return $builder->update(['accepted_at' => null]);
});
} | Add the `undoAccept` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addWithNotAccepted(Builder $builder): void
{
$builder->macro('withNotAccepted', function (Builder $builder) {
return $builder->withoutGlobalScope($this);
});
} | Add the `withNotAccepted` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addWithoutNotAccepted(Builder $builder): void
{
$builder->macro('withoutNotAccepted', function (Builder $builder) {
return $builder->withoutGlobalScope($this)->whereNotNull('accepted_at');
});
} | Add the `withoutNotAccepted` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addOnlyNotAccepted(Builder $builder): void
{
$builder->macro('onlyNotAccepted', function (Builder $builder) {
return $builder->withoutGlobalScope($this)->whereNull('accepted_at');
});
} | Add the `onlyNotAccepted` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
public function query($url, $data = null, $headers = array(), $method = 'get', $timeout = null)
{
$token = $this->getToken();
if (array_key_exists('expires_in', $token) && $token['created'] + $token['expires_in'] < time() + 20)
{
if (!$this->getOption('userefresh'))
{
return false;
}
$token = $... | Send a signed Oauth request.
@param string $url The URL for the request.
@param mixed $data The data to include in the request
@param array $headers The headers to send with the request
@param string $method The method with which to send the request
@param int $timeout The timeout for ... | entailment |
public function setToken($value)
{
if (\is_array($value) && !array_key_exists('expires_in', $value) && array_key_exists('expires', $value))
{
$value['expires_in'] = $value['expires'];
unset($value['expires']);
}
$this->setOption('accesstoken', $value);
return $this;
} | Set an option for the Client instance.
@param array $value The access token
@return Client This object for method chaining
@since 1.0 | entailment |
public function filter(array $items): array
{
$filtered = [];
foreach ($items as $commandName => $commandDefinition) {
if ($commandName === static::EXCLUDED) {
continue;
}
$isExcluded = true;
if ($this->shouldCommandBeAdded($commandNa... | @param array $items
@return array | entailment |
protected function shouldCommandBeAdded(string $commandName, array $commandDefinition): bool
{
$commandGroups = $this->getCommandGroups($commandDefinition);
if ($this->isCommandExcluded($commandName, $commandDefinition, $commandGroups)) {
return false;
}
if ($this->isGr... | @param string $commandName
@param array $commandDefinition
@return bool | entailment |
protected function isCommandExcluded(string $commandName, array $commandDefinition, array $commandGroups): bool
{
if ($this->isExcludedByName($commandName)) {
return true;
}
if ($this->isExcludedByDefinition($commandDefinition) && !$this->shouldBeIncluded($commandName, $commandG... | @param string $commandName
@param array $commandDefinition
@param array $commandGroups
@return bool | entailment |
protected function isGroupExcluded(array $commandGroups): bool
{
return (count($this->excludedCommandsAndGroups) > 0 && (count(array_intersect($this->excludedCommandsAndGroups, $commandGroups)) > 0));
} | @param array $commandGroups
@return bool | entailment |
protected function isGroupRequested(array $commandGroups): bool
{
return (count($this->groupsToBeExecuted) > 0 && (count(array_intersect($this->groupsToBeExecuted, $commandGroups)) > 0));
} | @param array $commandGroups
@return bool | entailment |
protected function shouldBeIncluded(string $commandName, array $commandGroups): bool
{
if (count($this->includeExcluded) > 0) {
return (in_array($commandName, $this->includeExcluded) || count(array_intersect($this->includeExcluded, $commandGroups)) > 0);
}
return false;
} | @param string $commandName
@param array $commandGroups
@return bool | entailment |
public function findCommand(string $name): CommandInterface
{
[$section, $command] = explode('/', $name);
return $this->stage->getSection($section)->getCommand($command);
} | @param string $name
@return \Spryker\Install\Stage\Section\Command\CommandInterface | entailment |
public function run(
CommandLineArgumentContainer $commandLineArgumentContainer,
CommandLineOptionContainer $commandLineOptionContainer,
StyleInterface $output
) {
$configuration = $this->configurationBuilder->buildConfiguration(
$commandLineArgumentContainer,
... | @param \Spryker\Install\CommandLine\CommandLineArgumentContainer $commandLineArgumentContainer
@param \Spryker\Install\CommandLine\CommandLineOptionContainer $commandLineOptionContainer
@param \Spryker\Style\StyleInterface $output
@return void | entailment |
protected function executeStage(ConfigurationInterface $configuration)
{
$stage = $configuration->getStage();
$configuration->getOutput()->startInstall($stage);
foreach ($stage->getSections() as $section) {
if ($section->isExcluded()) {
continue;
}
... | @param \Spryker\Install\Configuration\ConfigurationInterface $configuration
@return void | entailment |
public function setCookie(array $options): self
{
if (isset($options['name']) && is_string($options['name'])) {
//正常COOKIE的设定
$this->cookies->add($options);
} else {
if (key($options) === 0) {
//数组COOKIE的设定
foreach ($options as $par... | Set Cookie to Cookies->$cookie list, cookie of the same name will be overwritten
@param $options
@return $this | entailment |
public function unsetCookie(string $name, string $path = '', string $domain = ''): self
{
$this->cookies->add([
'name' => $name,
'expires' => -1,
'path' => $path,
'domain' => $domain,
]);
return $this;
} | Unset cookie
@param string $name
@param string $path
@param string $domain
@return $this | entailment |
protected function addAccept(Builder $builder): void
{
$builder->macro('accept', function (Builder $builder) {
$builder->withNotAccepted();
return $builder->update(['is_accepted' => 1]);
});
} | Add the `accept` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addWithoutNotAccepted(Builder $builder): void
{
$builder->macro('withoutNotAccepted', function (Builder $builder) {
return $builder->withoutGlobalScope($this)->where('is_accepted', 1);
});
} | Add the `withoutNotAccepted` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function addOnlyNotAccepted(Builder $builder): void
{
$builder->macro('onlyNotAccepted', function (Builder $builder) {
return $builder->withoutGlobalScope($this)->where('is_accepted', 0);
});
} | Add the `onlyNotAccepted` extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | entailment |
protected function loadUri($uri)
{
try {
// Try to load the file through PHP's include().
// Make sure we don't accidentally create output.
ob_start();
$data = include($uri);
ob_end_clean();
return $data;
} catch (Exception $ex... | Load the contents of an resource identified by an URI.
@since 0.4.0
@param string $uri URI of the resource.
@return array|null Raw data loaded from the resource. Null if no data found.
@throws FailedToLoadConfigException If the resource could not be loaded. | entailment |
public function getKey($_)
{
$keys = $this->validateKeys(func_get_args());
$keys = array_reverse($keys);
$array = $this->getArrayCopy();
while (count($keys) > 0) {
$key = array_pop($keys);
$array = $array[$key];
}
return $array;
} | Get the value of a specific key.
To get a value several levels deep, add the keys for each level as a comma-separated list.
@since 0.1.0
@since 0.1.4 Accepts list of keys.
@param string|array $_ List of keys.
@return mixed
@throws KeyNotFoundException If an unknown key is requested. | entailment |
public function hasKey($_)
{
try {
$keys = array_reverse($this->getKeyArguments(func_get_args()));
$array = $this->getArrayCopy();
while (count($keys) > 0) {
$key = array_pop($keys);
if (! array_key_exists($key, $array)) {
... | Check whether the Config has a specific key.
To check a value several levels deep, add the keys for each level as a comma-separated list.
@since 0.1.0
@since 0.1.4 Accepts list of keys.
@param string|array $_ List of keys.
@return bool | entailment |
public function getSubConfig($_)
{
$keys = $this->validateKeys(func_get_args());
$subConfig = clone $this;
$subConfig->reduceToSubKey($keys);
return $subConfig;
} | Get a new config at a specific sub-level.
@since 0.1.13
@param string|array $_ List of keys.
@return ConfigInterface
@throws KeyNotFoundException If an unknown key is requested. | entailment |
public function validateKeys($_)
{
$keys = $this->getKeyArguments(func_get_args());
if (! $this->hasKey($keys)) {
throw new KeyNotFoundException(
sprintf(
_('The configuration key %1$s does not exist.'),
implode('->', $keys)
... | Validate a set of keys to make sure they exist.
@since 0.1.13
@param string|array $_ List of keys.
@return array List of keys.
@throws KeyNotFoundException If an unknown key is requested. | entailment |
protected function getKeyArguments($arguments)
{
$keys = [];
foreach ($arguments as $argument) {
if (is_array($argument)) {
$keys = array_merge($keys, $this->getKeyArguments($argument));
}
if (is_string($argument)) {
$keys = array_m... | Recursively extract the configuration key arguments from an arbitrary array.
@since 0.1.6
@param array $arguments Array as fetched through get_func_args().
@return array Array of strings. | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.