sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function import(GitRepositoryEntity $gitRepository)
{
$importer = $this->app->make(TranslatableImporter::class);
$fetcher = $this->app->make(Fetcher::class, ['gitRepository' => $gitRepository]);
$packagesRepo = $this->app->make(PackageRepository::class);
$package = $packagesRe... | Import the strings from a git repository. | entailment |
protected function normalizeArgs(array $args)
{
$error = $this->app->make('helper/validation/error');
$normalized = [];
$normalized['territoryRequestLevel'] = null;
if (isset($args['territoryRequestLevel']) && (is_int($args['territoryRequestLevel']) || (is_string($args['territoryRequ... | {@inheritdoc}
@see BlockController::normalizeArgs() | entailment |
private function startStep($checkToken = null)
{
if ($this->getAccess()->isLoggedIn()) {
$result = true;
$token = $this->app->make('token');
if ($checkToken !== null && !$token->validate($checkToken)) {
$this->set('showError', $token->getErrorMessage());
... | @param null|string $checkToken
@return bool | entailment |
private function checkExistingLocale($localeID)
{
$result = null;
$localeRepo = $this->app->make(LocaleRepository::class);
$existing = $localeRepo->find($localeID);
if ($existing !== null) {
if ($existing->isSource()) {
$result = t("There couldn't be a lan... | @param string $localeID
@return string|null | entailment |
private function createLocale($localeID, $notes, $approve)
{
$locale = LocaleEntity::create($localeID)
->setRequestedBy($this->getAccess()->getUserEntity('current'))
->setRequestedOn(new DateTime())
->setIsApproved($approve)
;
$em = $this->app->make(Entity... | @param string $localeID
@param string $notes
@param bool $approve
@return LocaleEntity | entailment |
private function readCSVLine($fd)
{
for (; ;) {
$line = @fgetcsv($fd, 0, ',', '"');
if ($line === false) {
break;
}
if ($line === null) {
throw new Exception('Error in CSV file');
}
yield $line;
}... | @param resource $fd
@return array[array] | entailment |
private function parseMap(OutputInterface $output, array $line)
{
$output->write('Parsing CSV header... ');
$map = [];
$testLocales = [];
$numFields = 0;
$sourceFieldsFound = 0;
$m = null;
foreach ($line as $index => $field) {
if ($index !== $numFi... | @param array $line
@return array | entailment |
public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getObject();
if ($entity instanceof PackageVersionEntity) {
$this->refreshPackageLatestVersion($args->getObjectManager(), $entity->getPackage());
}
} | Callback method called when a new entity has been saved.
@param LifecycleEventArgs $args | entailment |
public function postUpdate(LifecycleEventArgs $args)
{
$entity = $args->getObject();
if ($entity instanceof PackageVersionEntity) {
$em = $args->getObjectManager();
/* @var \Doctrine\ORM\EntityManager $em */
$unitOfWork = $em->getUnitOfWork();
$changeS... | Callback method called when a modified entity is going to be saved.
@param LifecycleEventArgs $args | entailment |
public static function get($objectOrClass, $hook)
{
foreach (self::$hooks[$hook]['_global'] ?? [] as $callback) {
yield $callback;
}
$class = is_object($objectOrClass) ? get_class($objectOrClass) : (string) $objectOrClass;
foreach (self::$hooks[$hook][$class] ?? [] as $c... | @param object $objectOrClass
@param string $hook
@return \Traversable|\Closure[] | entailment |
public static function getHookId($object)
{
return (function($object) {
if (false == property_exists($object, 'hookId')) {
$object->hookId = null;
}
if (false == $object->hookId) {
$object->hookId = get_class($object).':'.uniqid('', true);... | @param object $object
@return string | entailment |
public function getByLocale(LocaleEntity $locale)
{
$app = Application::getFacadeApplication();
$result = $this->find($locale);
if ($result === null) {
$em = $this->getEntityManager();
try {
$numTranslatable = (int) $app->make(TranslatableRepository::c... | Get the stats for a specific locale.
If the stats does not exist yet, they are created.
@return LocaleStatsEntity | entailment |
public function resetForLocale(LocaleEntity $locale)
{
$this->createQueryBuilder('t')
->delete()
->where('t.locale = :locale')->setParameter('locale', $locale)
->getQuery()->execute();
} | Clear the stats for a specific locale.
@para LocaleEntity $locale | entailment |
protected function getGroup($name, $parent = null)
{
$name = trim($name, '/');
if ($parent === null || $parent === false || $parent === '') {
$parent = null;
$path = '/' . $name;
} else {
if (!$parent instanceof Group) {
$parent = $this->ge... | Get a user group (create it if it does not exist).
@param string $name the group name
@param string|Group|null $parent the parent group
@return \Group | entailment |
protected function getLocaleGroup($parentName, $locale)
{
if (!($locale instanceof LocaleEntity)) {
$l = $this->app->make(LocaleRepository::class)->findApproved($locale);
if ($l === null) {
throw new UserMessageException(t("The locale identifier '%s' is not valid", $l... | Get a locale group given its parent group name.
@param string $parentName
@param LocaleEntity|string $locale | entailment |
public function getGlobalAdministrators()
{
if ($this->globalAdministrators === null) {
$this->globalAdministrators = $this->getGroup(self::GROUPNAME_GLOBAL_ADMINISTRATORS);
}
return $this->globalAdministrators;
} | Get the global administrators group.
@return \Group | entailment |
public function decodeAspiringTranslatorsGroup(Group $group)
{
$result = null;
$match = null;
if (preg_match('/^\/' . preg_quote(self::GROUPNAME_ASPIRING_TRANSLATORS, '/') . '\/(.+)$/', $group->getGroupPath(), $match)) {
$result = $this->app->make(LocaleRepository::class)->findAp... | Check if a group is an aspiring translators group. If so returns the associated locale entity.
@param Group $group
@return LocaleEntity|null | entailment |
public function deleteLocaleGroups($localeID)
{
foreach ([
self::GROUPNAME_LOCALE_ADMINISTRATORS,
self::GROUPNAME_TRANSLATORS,
self::GROUPNAME_ASPIRING_TRANSLATORS,
] as $parentGroupName) {
$path = "/$parentGroupName/$localeID";
$group = Gr... | Delete the user groups associated to a locale ID.
@param string $localeID | entailment |
public function clear() {
$i=0;
if ($glob=@glob($this->f3->get('ASSETS.public_path').'*'))
foreach ($glob as $file)
if (preg_match('/.+?\.(js|css)/i',basename($file))) {
$i++;
@unlink($file);
}
return $i;
} | reset the temporary public path
@return integer | entailment |
public function getAssets($group='head',$type=null) {
$assets = array();
if (!isset($this->assets[$group]))
return $assets;
$types = array_keys($this->assets[$group]);
foreach($types as $asset_type) {
if ($type && $type!=$asset_type)
continue;
krsort($this->assets[$group][$asset_type]);
foreach(... | get sorted, unique assets from group
@param string $group which group to render
@param string $type which type to render, or all
@return array | entailment |
public function renderGroup($assets) {
$out = array();
if ($this->f3->get('ASSETS.trim_public_root')) {
$basePath=$this->f3->fixslashes(realpath($this->f3->fixslashes(
$_SERVER['DOCUMENT_ROOT'].$this->f3->get('BASE'))));
$cDir=$this->f3->fixslashes(getcwd());
$trimPublicDir=str_replace($cDir,'',$basePa... | render asset group
@param array $assets
@return string | entailment |
public function combine($collection) {
$public_path = $this->f3->get('ASSETS.combine.public_path');
if (empty($collection) || count($collection) <= 1)
return $collection;
$cfs=$this->f3->get('ASSETS.combine.slots');
$slots=array_fill_keys(array_keys($cfs),array());
$sn=array_flip($cfs);
// sort to slots
... | combine a whole asset group
@param $collection
@return array | entailment |
public function minify($collection) {
// check final path
$public_path = $this->f3->get('ASSETS.minify.public_path');
if (!is_dir($public_path))
mkdir($public_path,0777,true);
$type = false;
$inline_stack = array();
foreach($collection as $i=>&$asset) {
$type = $asset['type'];
if ($asset['origin']=... | minify each file in a collection
@param $collection
@return mixed | entailment |
public function fixRelativePaths($content,$path,$targetDir=null) {
// Rewrite relative URLs in CSS
$f3=$this->f3;
$method=$f3->get('ASSETS.fixRelativePaths');
if ($method!==FALSE) {
$webBase=$f3->get('BASE');
// fix base path (resolve symbolic links)
$basePath=$f3->fixslashes(realpath(
$f3->fixslas... | Rewrite relative URLs in CSS
@author Bong Cosca, from F3 v2.0.13, http://bit.ly/1Mwl7nq
@param string $content
@param string $path
@param string $targetDir
@return string | entailment |
public function relPath($from,$to) {
$expFrom = explode('/',$from);
$expTo = explode('/',$to);
$max=max(count($expFrom),count($expTo));
$rel = [];
$base=TRUE;
for ($i=0;$i<$max;$i++) {
if ($base && isset($expTo[$i]) && isset($expFrom[$i])
&& $expTo[$i] === $expFrom[$i])
continue;
else
$bas... | assemble relative path to go from A to B
@param $from
@param $to
@return string | entailment |
public function add($path,$type,$group='head',$priority=5,$slot=null,$params=null) {
if (!isset($this->assets[$group]))
$this->assets[$group]=array();
if (!isset($this->assets[$group][$type]))
$this->assets[$group][$type]=array();
$asset = array(
'path'=>$path,
'type'=>$type,
'slot'=>$slot
) + ($... | add an asset
@param string $path
@param string $type
@param string $group
@param int $priority
@param string $slot
@param array $params | entailment |
public function addJs($path,$priority=5,$group='footer',$slot=null) {
$this->add($path,'js',$group,$priority,$slot);
} | add a javascript asset
@param string $path
@param int $priority
@param string $group
@param null $slot | entailment |
public function addCss($path,$priority=5,$group='head',$slot=null) {
$this->add($path,'css',$group,$priority,$slot);
} | add a css asset
@param string $path
@param int $priority
@param string $group
@param null $slot | entailment |
public function addInline($content,$type,$group='head',$slot='inline') {
if (!isset($this->assets[$group]))
$this->assets[$group]=array();
if (!isset($this->assets[$group][$type]))
$this->assets[$group][$type]=array();
$this->assets[$group][$type][3][]=array(
'data'=>$content,
'type'=>$type,
'origi... | add inline script or styles
@param string $content
@param string $type
@param string $group
@param string $slot | entailment |
public function addNode($node) {
$src=false;
// find src
if (array_key_exists('src',$node))
$src = $node['src'];
elseif (array_key_exists('href',$node))
$src = $node['href'];
if ($src) {
// find type
if (!isset($node['type'])) {
if (preg_match('/.*\.(css|js)(?=[?#].*|$)/i',$src,$match))
$... | push new asset during template execution
@param $node
@return string | entailment |
function parseNode($node) {
$src=false;
$params = array();
if (isset($node['@attrib'])) {
$params = $node['@attrib'];
unset($node['@attrib']);
}
// find src
if (array_key_exists('src',$params))
$src = $params['src'];
elseif (array_key_exists('href',$params))
$src = $params['href'];
if ($src)... | parse node data on template compiling
@param $node
@return string | entailment |
function resolveAttr(array $attr) {
$out = '';
foreach ($attr as $key => $value) {
// build dynamic tokens
if (preg_match('/{{(.+?)}}/s', $value))
$value = $this->template->build($value);
if (preg_match('/{{(.+?)}}/s', $key))
$key = $this->template->build($key);
// inline token
if (is_numeric... | general bypass for unhandled tag attributes
@param array $attr
@return string | entailment |
static public function renderLinkCSSTag(array $node) {
if (isset($node['@attrib']))
// detect stylesheet link tags
if ((isset($node['@attrib']['type']) &&
$node['@attrib']['type'] == 'text/css') ||
(isset($node['@attrib']['rel']) &&
$node['@attrib']['rel'] == 'stylesheet')) {
$node['@attrib']['... | crawl <link> tags in greedy mode
@param array $node
@return mixed|string | entailment |
public function _head($node) {
unset($node['@attrib']);
$content = array();
// bypass inner content nodes
foreach ($node as $el)
$content[] = $this->template->build($el);
return '<head>'.implode("\n", $content).
$this->render('head')."\n".'</head>';
} | auto-append slot marker into <head>
@param $node
@return string | entailment |
public function _body($node) {
$params = '';
if (isset($node['@attrib'])) {
$params = $this->resolveAttr($node['@attrib']);
unset($node['@attrib']);
}
$content = array();
// bypass inner content nodes
foreach ($node as $el)
$content[] = $this->template->build($el);
return '<body'.$params.'>'.impl... | auto-append footer slot marker into <body>
@param $node
@return string | entailment |
public function map()
{
Route::namespace($this->namespace)->group(function (Router $router) {
/*
* Front office routes
*/
if ($page = TypiCMS::getPageLinkedToModule('news')) {
$router->middleware('public')->group(function (Router $router) us... | Define the routes for the application.
@return null | entailment |
public function actionCreate()
{
$stdout = '';
foreach ($this->db->schema->getTableSchemas() as $table) {
if ($table->name === $this->migrationTable) {
continue;
}
$stdout .= static::generateCreateTable($table->name).
static::genera... | Generates the 'createTable' code.
@return integer the status of the action execution | entailment |
public function actionDrop()
{
$stdout = '';
foreach ($this->db->schema->getTableSchemas() as $table) {
if ($table->name === $this->migrationTable) {
continue;
}
$stdout .= static::generateDropTable($table->name);
if (!empty($table->for... | Generates the 'dropTable' code.
@return integer the status of the action execution | entailment |
private static function generateColumns(array $columns, array $unique)
{
$definition = '';
foreach ($columns as $column) {
$tmp = sprintf(" '%s' => \$this->%s%s,\n",
$column->name, static::getSchemaType($column), static::other($column, $unique));
if (null ... | Returns the columns definition.
@param array $columns
@param array $unique unique indexes
@return string | entailment |
private static function generatePrimaryKey(array $pk, array $columns)
{
if (empty($pk)) {
return '';
}
// Composite primary keys
if (2 <= count($pk)) {
$compositePk = implode(', ', $pk);
return " 'PRIMARY KEY ($compositePk)',\n";
}
... | Returns the primary key definition.
@param array $pk
@param array $columns
@return string the primary key definition | entailment |
private function generateForeignKey($table)
{
if (empty($table->foreignKeys)) {
return;
}
$definition = "// fk: $table->name\n";
foreach ($table->foreignKeys as $fk) {
$refTable = '';
$refColumns = '';
$columns = '';
forea... | Returns the foreign key definition.
@param TableSchema[] $table
@return string|null foreign key definition or null | entailment |
private static function getSchemaType($column)
{
// primary key
if ($column->isPrimaryKey && $column->autoIncrement) {
if ('bigint' === $column->type) {
return 'bigPrimaryKey()';
}
return 'primaryKey()';
}
// boolean
if ('t... | Returns the schema type.
@param ColumnSchema[] $column
@return string the schema type | entailment |
private static function other($column, array $unique)
{
$definition = '';
// size
if (null !== $column->scale && 0 < $column->scale) {
$definition .= "($column->precision,$column->scale)";
} elseif (null !== $column->size && !$column->autoIncrement && 'tinyint(1)' !== $... | Returns the other definition.
@param ColumnSchema[] $column
@param array $unique
@return string the other definition | entailment |
private function byOption()
{
$option = new OptionForCli($this->interactor);
$option->setOption($this->option);
$option->execute();
} | Download by option.
@return void | entailment |
public function getModelRepository($config = null, $data = null)
{
return new Repository\ModelRepository($this->getRequest(), $config, $data);
} | @param array|null $config
@param array|null $data
@return Repository\ModelRepository | entailment |
public function getInputRepository($config = null, $data = null)
{
return new Repository\InputRepository($this->getRequest(), $config, $data);
} | @param $config
@param $data
@return Repository\InputRepository | entailment |
public function getSearchInputRepository($config = null, $data = null)
{
return new Repository\SearchInputRepository($this->getRequest(), $config, $data);
} | @param $config
@param $data
@return Repository\SearchInputRepository | entailment |
public function getSearchModelRepository($config = null, $data = null)
{
return new Repository\SearchModelRepository($this->getRequest(), $config, $data);
} | @param $config
@param $data
@return Repository\SearchModelRepository | entailment |
protected function write(array $record)
{
$url = sprintf(
'https://api.telegram.org/bot%s/sendMessage',
$this->botToken
);
$data = [
'chat_id' => $this->chatID,
'disable_web_page_preview' => true,
'parse_mode' => 'HTML',
];... | {@inheritdoc} | entailment |
public function add($input_data)
{
$data['inputs'] = [];
if (is_array($input_data)) {
foreach ($input_data as $image) {
$data['inputs'][] = $this->addNewImage($image);
}
} else {
$data['inputs'][] = $this->addNewImage($input_data);
... | Add Input Method
@param $input_data
@return array
@throws \Exception | entailment |
public function addNewImage(Input $image)
{
$data = [];
$data['data'] = [
'image' => $this->generateImageAddress($image->getImage(), $image->getImageMethod()),
];
if ($image->getId()) {
$data = $this->addImageId($data, $image->getId());
}
if... | Adds new Image to Custom Input
@param Input $image
@return array | entailment |
public function generateImageAddress(string $image, $method = null)
{
if ($method == Input::IMG_BASE64) {
return ['base64' => $image];
} elseif ($method == Input::IMG_PATH) {
if (!file_exists($image)) {
throw new FileNotFoundException($image);
}
... | Generate Image With Download Type
@param $image
@param null $method
@return array | entailment |
public function addImageConcepts(array $data, array $concepts)
{
$data['concepts'] = [];
foreach ($concepts as $concept) {
$data['concepts'][] = [
'id' => $concept->getId(),
'value' => $concept->getValue(),
];
}
return $data;
... | Adds Image Concepts to Image Data
@param array $data
@param array $concepts
@return array | entailment |
public function addImageMetadata(array $data, array $metadata)
{
$data['metadata'] = [];
foreach ($metadata as $meta_name => $meta_value) {
$data['metadata'][$meta_name] = $meta_value;
}
return $data;
} | Adds Image Metadaya to Image Data
@param array $data
@param array $metadata
@return array | entailment |
public function get()
{
$inputResult = $this->getRequest()->request(
'GET',
$this->getRequestUrl('inputs')
);
return $this->getInputsFromResult($inputResult);
} | Gets All Inputs
@return array
@throws \Exception | entailment |
public function getById($id)
{
$inputResult = $this->getRequest()->request(
'GET',
$this->getRequestUrl(sprintf('inputs/%s', $id))
);
if (isset($inputResult['input'])) {
$input = new Input($inputResult['input']);
} else {
throw new \Ex... | Gets Input By Id
@param $id
@return Input
@throws \Exception | entailment |
public function getStatus()
{
$statusResult = $this->getRequest()->request(
'GET',
$this->getRequestUrl('inputs/status')
);
if (isset($statusResult['counts'])) {
$status = $statusResult['counts'];
} else {
throw new \Exception('Status ... | Gets Status of your Inputs
@return array
@throws \Exception | entailment |
public function deleteById($id)
{
$deleteResult = $this->getRequest()->request(
'DELETE',
$this->getRequestUrl(sprintf('inputs/%s', $id))
);
return $deleteResult['status'];
} | Deletes Input By Id
@param $id
@return array | entailment |
public function deleteByIdArray(array $ids)
{
$data['ids'] = $ids;
$deleteResult = $this->getRequest()->request(
'DELETE',
$this->getRequestUrl('inputs'),
$data
);
return $deleteResult['status'];
} | Deletes Inputs By Id Array
@param array $ids
@return array | entailment |
public function updateInputConcepts(array $conceptsArray, $action)
{
$data['inputs'] = [];
foreach ($conceptsArray as $inputId => $inputConcepts) {
$input = [];
$input['id'] = (string)$inputId;
$input['data'] = [];
$input['data'] = $this->addImageConc... | Common Input's Concepts Update Method
@param array $conceptsArray
@param $action
@return array | entailment |
public function load()
{
if (empty($this->storage)) {
throw new Exception('Empty config storage');
}
$storage = $this->getStorage();
$storage->load();
return $this->fromArray($storage->get());
} | Loads config from storage
@return $this
@throws \Runn\Core\Exception | entailment |
public function handleRequest(RequestInterface $request, callable $next, callable $first)
{
$request = $this->authentication->authenticate($request);
return $next($request);
} | {@inheritdoc} | entailment |
protected function checkRequired()
{
$errors = new Exceptions();
foreach ($this->getRequiredKeys() as $required) {
if (!isset($this->$required)) {
$errors->add(new Exception('Required property "' . $required . '" is missing'));
}
}
if (!$errors... | Checks if all required properties are set
@return bool
@throws \Runn\Core\Exceptions | entailment |
private function getNotificationCategory(NotificationEntity $notification)
{
$fqnClass = $notification->getFQNClass();
if (!isset($this->categories[$fqnClass])) {
if (!class_exists($fqnClass, true)) {
$this->categories[$fqnClass] = sprintf('Unable to find the category cla... | @param string $fqnClass
@throws Exception
@return CategoryInterface | entailment |
public function createHelpMessage()
{
$m = 'Usage:' . PHP_EOL;
$m .= ' -h,--help' . PHP_EOL;
$m .= ' Display help message and exit.' . PHP_EOL;
$m .= ' -p platform (required)' . PHP_EOL;
$m .= ' Select platform [m]ac or [w]indows or [l]inux.' . PHP_EOL;
$m .=... | Create help message.
@return string | entailment |
private function _getopt()
{
$shortopts = OptionConfig::HELP; // help
$shortopts .= OptionConfig::PLATFORM . ':'; // platform
$shortopts .= OptionConfig::OUTPUT_DIR . ':'; // output dir.
$shortopts .= OptionConfig::SELENIUM_VER . ':'; // Selenium-Standalone-Ser... | Acquire command line option.
@return array | entailment |
public function getRegisteredParsers()
{
if ($this->parserInstances === null) {
$result = [];
foreach ($this->parsers as $parser) {
if ($parser instanceof ParserInterface) {
$result[] = $parser;
} else {
$instanc... | Get the list of registered parsers.
@throws UserMessageException
@return ParserInterface[] | entailment |
public function showShareButtons(
Twig_Environment $twigEnvironment,
array $options = array(),
array $providers = array()
) {
$this->shareButtonsRenderer->setTemplateEngine($twigEnvironment);
if (isset($providers)) {
$options['providers'] = $providers;
}
... | Renders share buttons bar template based on user settings.
@param \Twig_Environment $twigEnvironment
@param array $options
@param string[] $providers
@return string | entailment |
public static function getFile($tmp = true, $name = null)
{
return ($tmp ? realpath(sys_get_temp_dir()) : '').'/'.(null === $name ? uniqid() : $name);
} | Gets the file.
@param bool $tmp TRUE if the file should be in the "/tmp" directory else FALSE.
@param string|null $name The name.
@return string The file. | entailment |
public function run(InputInterface $input = null, OutputInterface $output = null)
{
if (null === $input) {
// rewrite the input for single command usage
$argv = $_SERVER['argv'];
$scriptName = array_shift($argv);
array_unshift($argv, 'lint');
array... | {@inheritdoc}
@SuppressWarnings(PHPMD.Superglobals) | entailment |
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
if ('version' != $command->getName()) {
$output->writeln($this->getLongVersion());
}
return parent::doRunCommand($command, $input, $output);
} | {@inheritdoc} | entailment |
protected function before()
{
if ($this->option->isSpecifiedHelp()) {
$this->interactor->out($this->option->createHelpMessage());
$this->interactor->quit();
}
if ($this->getPlatform() === '') {
$this->interactor->out('Please input platform(-' . OptionConf... | {@inheritdoc} | entailment |
public function setAuthorizationFlow($name, $flow, $authorizationUrl, $tokenUrl, $refreshUrl = null, array $scopes = null)
{
if (!isset($this->authFlows[$name])) {
$this->authFlows[$name] = [];
}
$this->authFlows[$name][] = [$flow, $authorizationUrl, $tokenUrl, $refreshUrl, $sco... | Configuration details for a supported OAuth Flow
@param string $name
@param integer $flow
@param string $authorizationUrl
@param string $tokenUrl
@param string|null $refreshUrl
@param array|null $scopes | entailment |
private function getGitRepositories(array $filter)
{
$allGitRepositories = $this->app->make(GitRepositoryRepository::class)->findAll();
if (empty($allGitRepositories)) {
throw new Exception('No git repository defined');
}
if (count($filter) === 0) {
$result = ... | @param string[] $filter
@throws Exception
@return \CommunityTranslation\Entity\GitRepository[] | entailment |
public static function pack($data, $returnJsonEncode = false) {
self::resetSchema();
if (!$returnJsonEncode) {
return self::encode($data);
}
return json_encode(self::encode($data));
} | Method RJson::pack($data), return compact array
@param $data
@param bool $returnJsonEncode
@return array|bool|string | entailment |
public static function unpack($data, $isJson = false) {
self::resetSchema();
if ( $isJson ) {
$data = json_decode($data);
}
return self::decode($data);
} | RJson Unpack
Example of use RJson::unpack($data);
@param $data
@param bool $isJson
@return array|bool|string | entailment |
private static function decode($data) {
if((is_array($data) && isset($data[0])) || (isset($data[0]) && !is_string($data[0]))) {
return self::parseArray($data);
} else if (is_null($data) || is_scalar($data)) {
return $data;
} else {
return self::decodeNewObject($data);
}
} | Decode Array collection
@param $data
@return array|bool | entailment |
protected function getVolatileDirectory()
{
if ($this->volatileDirectory === null) {
$this->volatileDirectory = $this->app->make(VolatileDirectory::class);
}
return $this->volatileDirectory;
} | Get the volatile instance that contains the decompressed contents of the package archive.
@return VolatileDirectory | entailment |
public function extract()
{
if ($this->extractedWorkDir !== null) {
return;
}
if (!is_file($this->packageArchive)) {
throw new UserMessageException(t('Archive not found: %s', $this->packageArchive));
}
try {
$workDir = $this->getVolatileDir... | Extract the archive (if not already done).
@throws UserMessageException | entailment |
public function repack()
{
$this->extract();
try {
$this->app->make('helper/zip')->zip($this->getVolatileDirectory()->getPath(), $this->packageArchive, ['includeDotFiles' => true]);
} catch (\Exception $x) {
throw new UserMessageException($x->getMessage());
}
... | Re-create the source archive with the contents of the extracted directory.
@throws UserMessageException | entailment |
public static function create($fqnClass, array $notificationData = [], $priority = null)
{
if (!is_numeric($priority)) {
$priority = 0;
if (class_exists($fqnClass) && class_exists(ReflectionClass::class)) {
$reflectionClass = new ReflectionClass($fqnClass);
... | Create a new (unsaved) instance.
@param string $fqnClass The fully qualified name of the category class
@param array $notificationData Data specific to the notification class
@param int|null $priority The notification priority (bigger values for higher priorities)
@return static | entailment |
public function setSentCountPotential($value = null)
{
if ($value === null || $value === '' || $value === false) {
$this->sentCountPotential = null;
} else {
$this->sentCountPotential = (int) $value;
}
return $this;
} | Set the number of actual recipients notified (null if not yed delivered).
@param int|null $value
@return static | entailment |
public function setSentCountActual($value = null)
{
if ($value === null || $value === '' || $value === false) {
$this->sentCountActual = null;
} else {
$this->sentCountActual = (int) $value;
}
return $this;
} | Set the number of actual recipients notified (null if not yed delivered).
@param int|null $value
@return static | entailment |
public function format($user)
{
$id = null;
$name = '';
$userInfo = null;
if (isset($user) && $user) {
if (is_int($user) || (is_string($user) && is_numeric($user))) {
$user = \User::getByUserID($user);
}
try {
if ($u... | Format a username.
@param int|ConcreteUser|UserInfo|ConcreteUserEntity $user
@return string | entailment |
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse): void
{
$httpResponse->setContentType($this->getContentType(), 'utf-8');
$httpResponse->setExpiration(FALSE);
$httpResponse->setCode($this->code);
echo Nette\Utils\Json::encode($this->getPayload(), Nette\Utils\Json::PRE... | {inheritDoc} | entailment |
public function getStickyRequest()
{
if ($this->stickyRequest === null) {
$this->stickyRequest = $this->app->make(StickyRequest::class, ['community_translation.packages']);
}
return $this->stickyRequest;
} | Get the instance of a class that holds the criteria of the last performed search.
@return StickyRequest | entailment |
public function getSearchList()
{
if ($this->searchList === null) {
$this->searchList = $this->app->make(SearchList::class, [$this->getStickyRequest()]);
}
return $this->searchList;
} | Get the instance of a class that defines the search list.
@return SearchList | entailment |
public function search($reset = false)
{
$stickyRequest = $this->getStickyRequest();
$searchList = $this->getSearchList();
if ($reset) {
$stickyRequest->resetSearchRequest();
}
$req = $stickyRequest->getSearchRequest();
$req = $stickyRequest->getSearchReq... | Perform the search.
@param bool $reset Should we reset all the previous search criteria? | entailment |
public function validateFile(FileReport $report)
{
$realPath = $report->getFile()->getRealPath();
if (false === is_file($realPath)) {
$report->reportProblem('file not found: ' . $realPath);
return false;
}
if (false === is_readable($realPath)) {
... | {@inheritdoc} | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setCommand(
$this->getApplication()->find(LintCommand::COMMAND_NAME)
);
parent::execute($input, $output);
} | {@inheritdoc} | entailment |
protected function getRecipientIDs(NotificationEntity $notification)
{
$result = [];
$notificationData = $notification->getNotificationData();
$locale = $this->app->make(LocaleRepository::class)->findApproved($notificationData['localeID']);
if ($locale === null) {
throw n... | {@inheritdoc}
@see Category::getRecipientIDs() | entailment |
public function getMailParameters(NotificationEntity $notification, UserInfo $recipient)
{
$notificationData = $notification->getNotificationData();
$locale = $this->app->make(LocaleRepository::class)->findApproved($notificationData['localeID']);
if ($locale === null) {
throw new... | {@inheritdoc}
@see Category::getMailParameters() | entailment |
public static function create($handle, $version, $archiveUrl)
{
$result = new static();
$result->id = null;
$result->handle = (string) $handle;
$result->name = '';
$result->url = '';
$result->approved = true;
$result->version = (string) $version;
$resu... | @param string $handle
@param string $version
@param string $archiveUrl
@return static | entailment |
public function getByHandle($handle)
{
return isset($this->converters[$handle]) ? $this->converters[$handle] : null;
} | Get a converter given its handle.
@param string $handle
@return ConverterInterface|null | entailment |
public function getByFileExtension($fileExtension)
{
$fileExtension = ltrim($fileExtension);
$result = [];
foreach ($this->converters as $converter) {
if (strcasecmp($fileExtension, $converter->getFileExtension()) === 0) {
$result[] = $converter;
}
... | Get the converter given a file extension.
@param string $fileExtension
@return ConverterInterface[] | entailment |
public function getRegisteredConverters()
{
$result = $this->converters;
$comparer = new Comparer();
usort($result, function (ConverterInterface $a, ConverterInterface $b) use ($comparer) {
return $comparer->compare($a->getName(), $b->getName());
});
return $resu... | Get the list of registered converters.
@throws UserMessageException
@return ConverterInterface[] | entailment |
public function filterByKeywords($name)
{
$likeBuilder = $this->app->make(LikeBuilder::class);
/* @var LikeBuilder $likeBuilder */
$likes = $likeBuilder->splitKeywordsForLike($name, '\W_');
if (!empty($likes)) {
$expr = $this->query->expr();
$orFields = $expr-... | Filter the results by keywords.
@param string $name | entailment |
public function getTotalResults()
{
$query = $this->deliverQueryObject();
$query
->resetQueryParts(['groupBy', 'orderBy'])
->select('count(distinct p.id)')
->setMaxResults(1);
$result = $query->execute()->fetchColumn();
return (int) $result;
} | {@inheritdoc}
@see \Concrete\Core\Search\ItemList\ItemList::getTotalResults() | entailment |
protected function createPaginationObject()
{
$adapter = new DoctrineDbalAdapter(
$this->deliverQueryObject(),
function (\Doctrine\DBAL\Query\QueryBuilder $query) {
$query
->resetQueryParts(['groupBy', 'orderBy'])
->select('coun... | {@inheritdoc}
@see \Concrete\Core\Search\ItemList\ItemList::createPaginationObject() | entailment |
public function getResult($queryRow)
{
$result = null;
$entityManager = $this->getEntityManager();
$package = $entityManager->find(PackageEntity::class, $queryRow['id']);
if ($package !== null) {
$result = [$package];
if ($this->localeStats !== null) {
... | {@inheritdoc}
@see \Concrete\Core\Search\ItemList\ItemList::getResult() | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.