sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function add_panel( $id, $args = [] ) {
$panel = $id instanceof Panel ? $id : new Panel( $this, $id, $args );
$this->panels[ $panel->id ] = $panel;
return $panel;
} | {@inheritdoc} | entailment |
public function get_panel( $id ) {
return isset( $this->panels[ $id ] ) ? $this->panels[ $id ] : null;
} | {@inheritdoc} | entailment |
public function save($selection = null)
{
// prepare the selection
if (func_num_args())
{
if (is_array($selection))
{
$filter = array();
foreach ($this->container as $file)
{
$match = true;
foreach($selection as $item => $value)
{
if ($value != $file->{$item})
{
... | Runs save on all loaded file objects
@param integer|string|array $selection | entailment |
public function isValid()
{
// loop through all files
foreach ($this->container as $file)
{
// return false at the first non-valid file
if ( ! $file->isValid())
{
return false;
}
}
// only return true if there are uploaded files, and they are all valid
return empty($this->container) ? fals... | Returns a consolidated status of all uploaded files
@return boolean | entailment |
public function getAllFiles($index = null)
{
// return the selection
if ($selection = (func_num_args() and ! is_null($index)) ? $this[$index] : $this->container)
{
// make sure selection is an array
is_array($selection) or $selection = array($selection);
}
else
{
$selection = array();
}
retur... | Returns the list of uploaded files
@param integer|string $index
@return File[] | entailment |
public function getValidFiles($index = null)
{
// prepare the selection
if (is_numeric($index))
{
$selection = $this->container;
}
else
{
$selection = (func_num_args() and ! is_null($index)) ? $this[$index] : $this->container;
}
// storage for the results
$results = array();
if ($selection)... | Returns the list of uploaded files that valid
@param integer|string $index
@return File[] | entailment |
public function register($event, $callback)
{
// check if this is a valid event type
if ( ! isset($this->callbacks[$event]))
{
throw new \InvalidArgumentException($event.' is not a valid event');
}
// check if the callback is acually callable
if ( ! is_callable($callback))
{
throw new \InvalidArgu... | Registers a callback for a given event
@param string $event
@param mixed $callback
@throws \InvalidArgumentException if not valid event or not callable second parameter | entailment |
public function setConfig($item, $value = null)
{
// unify the parameters
is_array($item) or $item = array($item => $value);
// update the configuration
foreach ($item as $name => $value)
{
// is this a valid config item? then update the defaults
array_key_exists($name, $this->defaults) and $this->def... | Sets the configuration for this file
@param string|array $item
@param mixed $value | entailment |
public function processFiles(array $selection = null)
{
// normalize the multidimensional fields in the $_FILES array
foreach($_FILES as $name => $file)
{
// was it defined as an array?
if (is_array($file['name']))
{
$data = $this->unifyFile($name, $file);
foreach ($data as $entry)
{
i... | Processes the data in the $_FILES array, unify it, and create File objects for them
@param mixed $selection | entailment |
protected function unifyFile($name, $file)
{
// storage for results
$data = array();
// loop over the file array
foreach ($file['name'] as $key => $value)
{
// we're not an the end of the element name nesting yet
if (is_array($value))
{
// recurse with the array data we have at this point
$... | Converts the silly different $_FILE structures to a flattened array
@param string $name
@param array $file
@return array | entailment |
protected function addFile(array $entry)
{
// add the new file object to the container
$this->container[] = new File($entry, $this->callbacks);
// and load it with a default config
end($this->container)->setConfig($this->defaults);
} | Adds a new uploaded file structure to the container
@param array $entry | entailment |
public function display( $field, $value, $builder ) {
$value = $this->parse_value( $value );
$html_builder = $builder->get_html_builder();
$system_fonts = wp_list_pluck( Webfonts::get_system_fonts(), 'label', 'name' );
$defaults = [
'font-family' => true,
'font-size' => true,
'font-weight'... | {@inheritdoc} | entailment |
public function getPermissions(RoleInterface $role)
{
$permissions = new ArrayCollection();
$iterator = new \RecursiveIteratorIterator(
new RecursivePermissionIterator($role->getPermissions()),
\RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as ... | {@inheritdoc} | entailment |
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$treeBuilder
->root('piedweb_cms')
->children()
->scalarNode('media_dir_absolute') // NOT USED ??
->defaultValue('%kernel.project_dir%/media')
... | php bin/console config:dump-reference PiedWebCMSBundle. | entailment |
public function render(RenderHandler $handler)
{
foreach ($this->comments as $comment) {
$handler->add(self::DIRECTIVE_COMMENT, $comment);
}
return true;
} | Render
@param RenderHandler $handler
@return bool | entailment |
public function saveMessage($mail)
{
try {
return $this->_storage->saveMessage($mail);
} catch (\Exception $e) {
throw new MailException(
new Phrase($e->getMessage()),
$e)
;
}
} | Send a mail using this transport
@param \Shockwavemk\Mail\Base\Model\Mail $mail
@return $id
@throws MailException | entailment |
public function saveAttachment($attachment)
{
try {
return $this->_storage->saveAttachment($attachment);
} catch (\Exception $e) {
throw new MailException(
new Phrase($e->getMessage()),
$e)
;
}
} | TODO
@param AttachmentInterface $attachment
@return string $id
@throws MailException | entailment |
public function loadMail($id)
{
try {
return $this->_storage->loadMail($id);
} catch (\Exception $e) {
throw new MailException(
new Phrase($e->getMessage()),
$e)
;
}
} | Use the concrete storage implementation to load the mail to storage
@return \Shockwavemk\Mail\Base\Model\Mail
@throws MailException | entailment |
public function loadAttachment($mail, $path)
{
try {
return $this->_storage->loadAttachment($mail, $path);
} catch (\Exception $e) {
throw new MailException(
new Phrase($e->getMessage()),
$e)
;
}
} | TODO
@param \Shockwavemk\Mail\Base\Model\Mail $mail
@param string $path
@return AttachmentInterface
@throws MailException | entailment |
public function getMailFolderPathById($mailId)
{
try {
return $this->_storage->getMailFolderPathById($mailId);
} catch (\Exception $e) {
throw new MailException(
new Phrase($e->getMessage()),
$e)
;
}
} | TODO
@return string
@throws MailException | entailment |
public function jsonSerialize()
{
$data = $this->getData();
$data['binary'] = '';
$data['mail'] = $this->getMail()->getId();
return $data;
} | Return all data, except binary
@return array | entailment |
public function toMimePart()
{
/** @var Zend_Mime_Part $attachmentMimePart */
$attachmentMimePart = new Zend_Mime_Part($this->getBinary());
$attachmentMimePart->type = $this->getMimeType();
$attachmentMimePart->disposition = $this->getDisposition();
$attachmentMimePart->enco... | Returns a mime part converted attachment
@return Zend_Mime_Part | entailment |
public function getBinary()
{
/** @noinspection IsEmptyFunctionUsageInspection */
if (empty($this->getData('binary'))) {
$attachmentBinary = file_get_contents(
$this->getFilePath()
);
$this->setData(
'binar... | Returns binary data of a single attachment file
@return string binary data of attachment file
@throws \Magento\Framework\Exception\MailException | entailment |
public function getDisposition()
{
/** @noinspection IsEmptyFunctionUsageInspection */
if (empty($this->getData('disposition'))) {
$this->setData(
'disposition',
Zend_Mime::DISPOSITION_ATTACHMENT
);
}
return $this->getData('dis... | Returns current setting of how to integrate attachment into message
@return string | entailment |
public function active() {
// Default to showing the section.
$show = true;
// Use the callback to determine showing the section, if it exists.
if ( is_callable( $this->active_callback ) ) {
$show = call_user_func( $this->active_callback, $this );
}
return $show;
} | Check whether section is active to current screen.
@return bool | entailment |
public function check_capabilities() {
if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
return false;
}
if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
return false;
}
return true;
... | Checks required user capabilities and whether the theme has the
feature support required by the section.
@return bool | entailment |
public function icon() {
if ( ! $this->icon ) {
return '';
}
if ( 0 === strpos( $this->icon, 'dashicons-' ) ) {
$icon_html = '<span class="wplibs-menu-icon dashicons ' . esc_attr( $this->icon ) . '"></span>';
} elseif ( 0 === strpos( $this->icon, 'suru-icon-' ) ) {
$icon_html = '<span class="wplibs-me... | Show the section/panel icon as HTML.
@return string | entailment |
public function addChild(PermissionInterface $permission)
{
if (!$this->hasChild($permission)) {
$permission->setParent($this);
$this->children->add($permission);
}
} | {@inheritdoc} | entailment |
public function removeChild(PermissionInterface $permission)
{
if ($this->hasChild($permission)) {
$permission->setParent(null);
$this->children->removeElement($permission);
}
} | {@inheritdoc} | entailment |
public function buildZip($file, $basePath)
{
yield 'Generating zip file ' . $file;
$zip = new \ZipArchive();
$res = $zip->open($file, \ZipArchive::CREATE);
if ($res === true) {
$this->buildZipArchive($basePath, $zip, $basePath, 0);
$zip->close();
... | Creates a zip archive for the provided file using all files located at
the base path
@param string $file
@param string $basePath
@return \Generator | entailment |
public static function check( array $fields, array $data ) {
$dependency = new static( $data );
foreach ( $fields as $field ) {
if ( ! $field->get_option( 'deps' ) ) {
continue;
}
$satisfied = $dependency->apply(
$deps = $field->get_option( 'deps' )
);
$field->set_option( 'row_attributes',... | Check the fields dependencies.
@param \WPLibs\Form\Contracts\Field[] $fields
@param array $data
@return void | entailment |
public function apply( $rules ) {
$satisfied = true;
if ( empty( $rules ) || ! is_array( $rules ) ) {
return $satisfied;
}
// If no any valid rules, consider as satisfied.
if ( ! is_null( $rule = $this->get_rule( $rules ) ) ) {
return $rule->apply( $this->data );
}
return $satisfied;
} | Check rules is satisfied the conditions.
@param array $rules
@return bool | entailment |
public function get_rule( array $rules ) {
$logical = static::LOGICAL_AND;
if ( static::is_group_rules( $rules ) ) {
list( $logical, $rules ) = $this->parse_group_logical( $rules );
}
return $this->create_rule( $rules, $logical );
} | Gets the rule.
@param array $rules
@return \WPLibs\Rules\Rule|null | entailment |
public function create_rule( array $rules, $logical = 'and' ) {
if ( empty( $rules ) ) {
return null;
}
if ( static::is_proposition( $rules ) ) {
$rules = [ $rules ];
}
if ( ! $props = $this->build_propositions( $rules ) ) {
return null;
}
// Correct the "or" logical in case we have only one p... | Create new rule based on an array of rules.
@param array $rules
@param string $logical
@return \WPLibs\Rules\Rule|null | entailment |
protected function build_propositions( array $rules ) {
$props = [];
foreach ( $rules as $rule ) {
if ( ! is_array( $rule ) || ! static::is_proposition( $rule ) ) {
continue;
}
try {
$props[] = $this->create_proposition( ... $rule );
} catch ( \Exception $e ) {
continue;
}
}
return... | Build propositions based given array rules.
@param array $rules
@return array | entailment |
protected function create_proposition( $parent_name, $operator = null, $check_value = null ) {
list( $operator, $check_value ) = $this->normalize_proposition( $operator, $check_value );
// Allow check value can be a reference value of a variable in the context.
// This can be done with: ['some-check', '!=', '@an... | Create a rule proposition.
@param string $parent_name
@param string $operator
@param mixed $check_value
@return mixed | entailment |
protected function normalize_proposition( $operator = null, $check_value = null ) {
// Here we will make some assumptions about the operator. If only $operator are
// passed to the method, we will assume that the operator is an equals sign
// and keep going. Otherwise, we'll require the operator to be passed in.
... | Normalize the proposition.
@param string $operator
@param mixed $check_value
@return array
@throws \InvalidArgumentException | entailment |
public function add($line)
{
$array = preg_split('/\s+/', $line, 2);
$parts = array_map('trim', explode('/', $array[0]));
if (count($parts) != 2) {
return false;
}
$unit = strtolower(substr(preg_replace('/[^A-Za-z]/', '', filter_var($parts[1], FILTER_SANITIZE_STRI... | Add
@param string $line
@return bool | entailment |
private function getRatio($rate, $time)
{
$gcd = $this->getGCD($rate, $time);
$requests = $rate / $gcd;
$time = $time / $gcd;
$suffix = 's';
foreach ($this->units as $unit => $sec) {
if ($time % $sec === 0) {
$suffix = $unit;
$time ... | Get ratio string
@param int $rate
@param int $time
@return string | entailment |
private function getGCD($a, $b)
{
if (extension_loaded('gmp')) {
return gmp_intval(gmp_gcd((string)$a, (string)$b));
}
$large = $a > $b ? $a : $b;
$small = $a > $b ? $b : $a;
$remainder = $large % $small;
return 0 === $remainder ? $small : $this->getGCD($s... | Returns the greatest common divisor of two integers using the Euclidean algorithm.
@param int $a
@param int $b
@return int | entailment |
public function client($userAgent = self::USER_AGENT, $fallbackValue = 0)
{
$this->sort();
return new RequestRateClient($this->base, $userAgent, $this->requestRates, $fallbackValue);
} | Client
@param string $userAgent
@param float|int $fallbackValue
@return RequestRateClient | entailment |
private function sort()
{
if (!$this->sorted) {
$this->sorted = true;
return usort($this->requestRates, function (array $requestRateA, array $requestRateB) {
// PHP 7: Switch to the <=> "Spaceship" operator
return $requestRateB['rate'] > $requestRateA[... | Sort
@return bool | entailment |
public function render(RenderHandler $handler)
{
$this->sort();
foreach ($this->requestRates as $array) {
$time = '';
if (isset($array['from']) &&
isset($array['to'])
) {
$time .= ' ' . $array['from'] . '-' . $array['to'];
... | Render
@param RenderHandler $handler
@return bool | entailment |
public function save(\Magento\Framework\Model\AbstractModel $object)
{
$object->setHasDataChanges(true);
return parent::save($object);
} | {@inheritdoc} | entailment |
public function setStartDay($startDay)
{
$startDay = (int) $startDay;
if ($startDay < 1 || $startDay > 7) {
throw new OutOfRangeException(
"'$startDay' is an invalid value for \$startDay in '"
. __METHOD__
);
}
$this->startDay... | Set which day to display as the starting day of the week.
@param int $startDay
@return self | entailment |
public function showMonth($year, $month)
{
if (null !== $this->partial) {
$partial = $this->view->plugin('partial');
$params = array(
'calendar' => $this->calendar,
'startDay' => $this->startDay,
'year' => $year,
'm... | Returns the HTML to display a month.
@param int $year
@param int $month
@return void | entailment |
public function run()
{
$hostInfo = Yii::$app->getRequest()->getHostInfo();
$controller = $this->controller;
if (($serviceUrl = $this->serviceUrl) === null) {
$serviceUrl = $hostInfo . Url::toRoute([$this->getUniqueId(), $this->serviceVar => 1]);
}
if (($wsdlUrl =... | Runs the action.
If the GET parameter {@link serviceVar} exists, the action handle the remote method invocation.
If not, the action will serve WSDL content;
@throws \ReflectionException
@throws \yii\base\InvalidConfigException | entailment |
public function isLeap()
{
if (0 !== $this->year % 4) {
return false;
}
if (0 !== $this->year % 100) {
return true;
}
if (0 !== $this->year % 400) {
return false;
}
return true;
} | Checks if this year is a leap year.
@return bool | entailment |
public function getDocumentation($version = null)
{
return $this->routesMethodService->getDocumentation(
$this->context->getRouteId(),
$version,
$this->context->getPath()
);
} | Select all methods from the routes method table and build a resource
based on the data. If the route is in production mode read the schema
from the cache else resolve it
@param integer $version
@return \PSX\Api\Resource|null | entailment |
private function getHostname()
{
$host = parse_url($this->config->get('psx_url'), PHP_URL_HOST);
if (empty($host)) {
$host = $_SERVER['SERVER_NAME'];
}
return $host;
} | Tries to determine the current hostname
@return string | entailment |
private function handlerAdd($group)
{
if (!in_array($group, array_keys($this->handler))) {
$this->handler[$group] = new SubDirectiveHandler($this->base, $group);
return true;
}
return false;
} | Add sub-directive handler
@param string $group
@return bool | entailment |
public function add($line)
{
if ($line == '' ||
($pair = $this->generateRulePair($line, [-1 => self::DIRECTIVE_USER_AGENT] + array_keys(self::SUB_DIRECTIVES))) === false) {
return $this->append = false;
}
if ($pair[0] === self::DIRECTIVE_USER_AGENT) {
retu... | Add line
@param string $line
@return bool | entailment |
public function setConfig($item, $value = null)
{
// unify the parameters
is_array($item) or $item = array($item => $value);
// update the configuration
foreach ($item as $name => $value)
{
array_key_exists($name, $this->config) and $this->config[$name] = $value;
}
} | Sets the configuration for this file
@param string|array $item
@param mixed $value | entailment |
public function validate()
{
// reset the error container and status
$this->errors = array();
$this->isValid = true;
// validation starts, call the pre-validation callback
$this->runCallbacks('before_validation');
// was the upload of the file a success?
if ($this->container['error'] == 0)
{
// ad... | Runs validation on the uploaded file, based on the config being loaded
@return boolean | entailment |
public function save()
{
$tempfileCreated = false;
// we can only save files marked as valid
if ($this->isValid)
{
// make sure we have a valid path
if (empty($this->container['path']))
{
$this->container['path'] = rtrim($this->config['path'], DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
}
//... | Saves the uploaded file
@return boolean
@throws \DomainException if destination path specified does not exist | entailment |
protected function runCallbacks($type)
{
// make sure we have callbacks of this type
if (array_key_exists($type, $this->callbacks))
{
// run the defined callbacks
foreach ($this->callbacks[$type] as $callback)
{
// check if the callback is valid
if (is_callable($callback))
{
// call the... | Runs callbacks of he defined type
@param callable $type | entailment |
protected function normalize()
{
// Decode all entities to their simpler forms
$this->container['filename'] = html_entity_decode($this->container['filename'], ENT_QUOTES, 'UTF-8');
// Remove all quotes
$this->container['filename'] = preg_replace("#[\"\']#", '', $this->container['filename']);
// Strip unwan... | Converts a filename into a normalized name. only outputs 7 bit ASCII characters. | entailment |
protected function addError($error)
{
$this->errors[] = new FileError($error, $this->config['langCallback']);
$this->isValid = false;
} | Adds a new error object to the list
@param integer $error | entailment |
public static function initialize() {
foreach ( static::$core_types as $name => $class ) {
static::register( $name, new $class );
}
foreach ( static::$bindings as $name => $binding ) {
if ( ! static::resolved( $name ) ) {
static::fire( $name, $binding['callback'], $binding['sanitizer'] );
static::... | Initialize the custom fields.
@return void | entailment |
public static function register( $name, $callback = null, $sanitizer = null ) {
unset( static::$resolved[ $name ] );
if ( $callback instanceof Field_Type ) {
$instance = $callback;
list( $callback, $sanitizer ) = [
[ $instance, 'display' ],
[ $instance, 'sanitization' ],
];
static::$instances... | Register a custom field type.
@param string $name
@param callable|Field_Type $callback
@param callable $sanitizer
@return void | entailment |
public static function fire( $name, callable $callback, $sanitizer = null ) {
add_action( "cmb2_render_{$name}", static::get_render_callback( $callback ), 10, 5 );
if ( ! is_null( $sanitizer ) && is_callable( $sanitizer ) ) {
add_filter( "cmb2_sanitize_{$name}", static::get_sanitize_callback( $sanitizer ), 10, ... | Fire the hooks to add field type in to the CMB2.
@param string $name
@param callable $callback
@param callable $sanitizer | entailment |
public static function print_js_templates() {
foreach ( static::$instances as $type => $control ) {
if ( ! method_exists( $control, 'template' ) ) {
continue;
}
?>
<script type="text/html" id="tmpl-wplibs-field-<?php echo esc_attr( $type ); ?>-content">
<?php $control->template(); ?>
</script>... | Print the field JS templates.
@return void | entailment |
protected static function get_render_callback( $callback ) {
/**
* Rendering the field.
*
* @param Field $field The passed in `CMB2_Field` object.
* @param mixed $escaped_value The value of this field escaped.
* @param int $object_id The ID of the current object.
* @p... | Get the render field callback.
@param callable $callback
@return \Closure | entailment |
protected static function get_sanitize_callback( $sanitize_cb ) {
/**
* Filter the value before it is saved.a
*
* @param bool|mixed $check The check variable.
* @param mixed $value The value to be saved to this field.
* @param int $object_id The ID of the object where... | Get the sanitize callback.
@param callable $sanitize_cb The sanitize callback.
@return \Closure | entailment |
public static function syncConfig(Connection $connection, array $configs, \Closure $callback)
{
foreach ($configs as $row) {
$config = $connection->fetchAssoc('SELECT id, name FROM fusio_config WHERE name = :name', [
'name' => $row['name']
]);
if (empty($... | Helper method to sync all config values of an existing system
@param \Doctrine\DBAL\Connection $connection
@param array $configs
@param \Closure $callback | entailment |
public static function syncRoutes(Connection $connection, array $routes, \Closure $callback)
{
$scopes = [];
$maxId = (int) $connection->fetchColumn('SELECT MAX(id) AS max_id FROM fusio_routes');
foreach ($routes as $row) {
$route = $connection->fetchAssoc('SELECT id, status, p... | Helper method to sync all routes of an existing system
@param \Doctrine\DBAL\Connection $connection
@param array $routes
@param \Closure $callback | entailment |
public function getViewHelperConfig()
{
return array(
'factories' => array(
'calendar' => function ($vhm) {
$helper = new \BmCalendar\View\Helper\Calendar();
$helper->setRenderer(new \BmCalendar\Renderer\HtmlCalendar());
... | {@inheritDoc}
@return array | entailment |
public function toOptionArray()
{
$selection = array();
foreach ($this->config->getStorageTypes() as $storageType)
{
$selection[] = [
'label' => __($storageType['label']),
'value' => $storageType['value']
];
}
return $... | {@inheritdoc} | entailment |
public function monthTitle(Month $month)
{
$weekendClass = 'bm-calendar-weekend';
$monthName = self::$monthNames[$month->value()];
$output = '<thead>';
$output .= '<tr>';
$output .= '<th colspan="7" class="bm-calendar-month-title">' . $monthName . '</th>';
$outpu... | Returns the markup for the header of a month table.
@param Month $month
@return string | entailment |
public function renderDay(DayInterface $day)
{
$classes = array();
$dayOfWeek = $day->dayOfWeek();
if (DayInterface::SATURDAY === $dayOfWeek || DayInterface::SUNDAY === $dayOfWeek) {
$classes[] = 'bm-calendar-weekend';
}
foreach ($day->getStates() as $state) {
... | Returns the markup for a single table cell.
@param DayInterface $day
@return string | entailment |
public function renderMonth($year, $month)
{
$monthClass = sprintf('bm-calendar-month-%02d', $month);
$yearClass = sprintf('bm-calendar-year-%04d', $year);
$month = $this->calendar->getMonth($year, $month);
$days = $this->calendar->getDays($month);
$column = 0;
... | Render a month table internally.
@param int $yearNo
@param int $monthNo
@return string | entailment |
protected function getCommandConfig($commandKey)
{
if (isset($this->configsPerCommandKey[$commandKey])) {
return $this->configsPerCommandKey[$commandKey];
}
$config = new Config($this->config->get('default')->toArray(), true);
if ($this->config->__isset($commandKey)) {
... | Gets the config for given command key
@param string $commandKey
@return Config | entailment |
protected function getCommandsRunning()
{
$commandKeys = array();
foreach (new \APCIterator('user', '/^' . ApcStateStorage::CACHE_PREFIX . '/') as $counter) {
// APC entries do not expire within one request context so we have to check manually:
if ($counter['creation_time'] +... | Finds all commands currently running (having any metrics recorded within the statistical rolling window).
@return array
@throws \RuntimeException When entry with invalid name found in cache | entailment |
public function getStatsForCommandsRunning()
{
$stats = array();
$commandKeys = $this->getCommandsRunning();
foreach ($commandKeys as $commandKey) {
$commandConfig = $this->getCommandConfig($commandKey);
$commandMetrics = $this->commandMetricsFactory->get($commandKey,... | Finds all commands currently running (having any metrics recorded within the statistical rolling window).
For each command key prepares a set of statistic. Returns all sets.
@return array | entailment |
public function saveMessage($mail)
{
// convert message to html
$messageHtml = quoted_printable_decode(
$mail->getMessage()->getBodyHtml(true)
);
$this->createFolder(
$this->getMailFolderPathById($mail->getId())
);
// try to store message to ... | Save file to spool path
@param \Shockwavemk\Mail\Base\Model\Mail $mail
@return $this
@throws \Magento\Framework\Exception\MailException
@throws \Magento\Framework\Exception\FileSystemException
@throws \Exception | entailment |
protected function createFolder($folderPath)
{
if(!@mkdir($folderPath,0777,true) && !is_dir($folderPath))
{
throw new FileSystemException(
new Phrase('Folder can not be created, but does not exist.')
);
}
return $this;
} | Create a folder path, if folder does not exist
@param $folderPath
@return $this
@throws \Magento\Framework\Exception\FileSystemException | entailment |
protected function storeFile($data, $filePath)
{
// create a folder for message if needed
if (!is_dir(dirname($filePath))) {
$this->createFolder(dirname($filePath));
}
/** @noinspection LoopWhichDoesNotLoopInspection */
for ($i = 0; $i < $this->_config->getHostRe... | Stores string data at a given path
@param $data
@param $filePath
@return bool
@throws \Magento\Framework\Exception\FileSystemException
@throws \Exception | entailment |
public function loadMessage($mail)
{
$localFilePath = $this->getMailFolderPathById($mail->getId()) .
DIRECTORY_SEPARATOR . self::MESSAGE_FILE_NAME;
$messageJson = $this->restoreFile($localFilePath);
if (empty($messageJson)) {
$messageJson = '{}';
}
... | Restore a message from filesystem
@param \Shockwavemk\Mail\Base\Model\Mail $mail
@return \Shockwavemk\Mail\Base\Model\Mail\Message $message
@throws \Exception
@throws \Zend_Mail_Exception | entailment |
private function restoreFile($filePath)
{
try {
for ($i = 0; $i < $this->_config->getHostRetryLimit(); ++$i) {
/* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */
@fopen($filePath, 'x');
if (fals... | Load binary file data from a given file path
@param $filePath
@return null|string | entailment |
public function saveMail($mail)
{
// first save file to spool path
// to avoid exceptions on external storage provider connection
// convert message to json
$mailJson = json_encode($mail);
$this->createFolder(
$this->getMailFolderPathById($mail->getId())
... | Convert a mail object to json and store it at mail folder path
@param \Shockwavemk\Mail\Base\Model\Mail $mail
@return bool
@throws \Magento\Framework\Exception\FileSystemException
@throws \Exception | entailment |
public function loadMail($id)
{
/** @var \Shockwavemk\Mail\Base\Model\Mail $mail */
$mail = $this->_objectManager->create('Shockwavemk\Mail\Base\Model\Mail');
$mail->setId($id);
$localFilePath = $this->getMailFolderPathById(
$mail->getId()) .
... | Loads json file from storage and converts/parses it to a new mail object
@param int $id folder name / id eg. pub/media/emails/66
@return \Shockwavemk\Mail\Base\Model\Mail
@throws \Exception | entailment |
public function loadAttachment($mail, $path)
{
$attachmentFolder = DIRECTORY_SEPARATOR . self::ATTACHMENT_PATH;
$localFilePath = $this->getMailFolderPathById($mail->getId()) .
$attachmentFolder . $path;
return $this->restoreFile($localFilePath);
} | Load binary data from storage provider
@param \Shockwavemk\Mail\Base\Model\Mail $mail
@param string $path
@return string | entailment |
public function getAttachments($mail)
{
/** @noinspection IsEmptyFunctionUsageInspection */
if(empty($mail->getId())) {
return [];
}
$folderFileList = $this->getMailLocalFolderFileList($mail);
$attachments = [];
foreach ($folderFileList ... | Returns attachments for a given mail
\Shockwavemk\Mail\Base\Model\Mail $mail
@return \Shockwavemk\Mail\Base\Model\Mail\Attachment[] | entailment |
protected function getMailLocalFolderFileList($mail)
{
$spoolFolder = $this->_config->getHostSpoolerFolderPath() .
DIRECTORY_SEPARATOR .
$mail->getId() .
DIRECTORY_SEPARATOR .
self::ATTACHMENT_PATH;
// create a folder for attachments if needed
... | Get file list for a given mail
@param \Shockwavemk\Mail\Base\Model\Mail $mail
@return array | entailment |
public function saveAttachments($mail)
{
/** @var \Shockwavemk\Mail\Base\Model\Mail\Attachment[] $attachments */
$attachments = $mail->getAttachments();
foreach ($attachments as $attachment) {
$this->saveAttachment($attachment);
}
return $this;
} | Save all attachments of a given mail
@param \Shockwavemk\Mail\Base\Model\Mail $mail
@return $this
@throws \Magento\Framework\Exception\FileSystemException
@throws \Magento\Framework\Exception\MailException
@throws \Exception | entailment |
public function saveAttachment($attachment)
{
$binaryData = $attachment->getBinary();
/** @var \Shockwavemk\Mail\Base\Model\Mail $mail */
$mail = $attachment->getMail();
$folderPath = $this->getMailFolderPathById($mail->getId()) .
DIRECTORY_SEPARATOR .
self::... | Save an attachment binary to a file in host temp folder
@param \Shockwavemk\Mail\Base\Model\Mail\Attachment $attachment
@return int $id
@throws \Magento\Framework\Exception\FileSystemException
@throws \Magento\Framework\Exception\MailException
@throws \Exception | entailment |
public function getRootLocalFolderFileList()
{
$spoolFolder = $this->_config->getHostSpoolerFolderPath();
/** @var IteratorIterator $objects */
$objects = new IteratorIterator(
new DirectoryIterator($spoolFolder)
);
/** @var array $files */
$files = [];
... | Get Folder list for host spooler folder path
@return string[] | entailment |
public function getLocalFileListForPath($localPath)
{
$files = [];
$objects = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($localPath),
RecursiveIteratorIterator::LEAVES_ONLY,
FilesystemIterator::SKIP_DOTS
);
/**
* @var s... | Get list of files in a local file path
@param $localPath
@return string[] | entailment |
public function deleteLocalFiles($localPath)
{
$it = new RecursiveDirectoryIterator(
$localPath,
RecursiveDirectoryIterator::SKIP_DOTS
);
$files = new RecursiveIteratorIterator(
$it,
RecursiveIteratorIterator::CHILD_FIRST
);
f... | Deletes all local stored files
@param $localPath
@return \Shockwavemk\Mail\Base\Model\Storages\DefaultStorage | entailment |
public function setAttribute($userId, $name, $value)
{
$row = $this->connection->fetchAssoc('SELECT id FROM fusio_user_attribute WHERE name = :name', ['name' => $name]);
if (empty($row)) {
$this->connection->insert('fusio_user_attribute', [
'user_id' => $userId,
... | Sets a specific user attribute
@param integer $userId
@param string $name
@param string $value | entailment |
private function getSubmittedVersionNumber(RequestInterface $request)
{
$accept = $request->getHeader('Accept');
$matches = array();
preg_match('/^application\/vnd\.([a-z.-_]+)\.v([\d]+)\+([a-z]+)$/', $accept, $matches);
return isset($matches[2]) ? $matches[2] : null;
} | Returns the version number which was submitted by the client in the
accept header field
@return integer | entailment |
private function generateRulePair($line, array $whiteList)
{
// Split by directive and rule
$pair = array_map('trim', explode(':', $line, 2));
// Check if the line contains a rule
if (empty($pair[1]) ||
empty($pair[0]) ||
!in_array(($pair[0] = str_ireplace(arr... | Generate directive/rule pair
@param string $line
@param string[] $whiteList
@return string[]|false | entailment |
private function draftParseTime($string)
{
$array = explode('-', str_replace('+', '', filter_var($string, FILTER_SANITIZE_NUMBER_INT)), 3);
if (count($array) !== 2 ||
($fromTime = date_create_from_format('Hi', $array[0], $dtz = new DateTimeZone('UTC'))) === false ||
($toTime ... | Client timestamp range as specified in the `Robot exclusion standard` version 2.0 draft
@link http://www.conman.org/people/spc/robots2.html#format.directives.visit-time
@param $string
@return string[]|false | entailment |
public function hasPermission(RoleInterface $role, $permissionCode)
{
if ($this->cache->contains($this->getCacheKey($role))) {
return in_array($permissionCode, $this->cache->fetch($this->getCacheKey($role)));
}
$permissions = $this->map->getPermissions($role);
$permissio... | {@inheritdoc} | entailment |
private function parseTxt($txt)
{
$result = [];
$lines = array_map('trim', mb_split('\r\n|\n|\r', $txt));
// Parse each line individually
foreach ($lines as $key => $line) {
// Limit rule length
$line = mb_substr($line, 0, self::MAX_LENGTH_RULE);
/... | Client robots.txt
@param string $txt
@return bool | entailment |
private function parseLine($line)
{
if (($pair = $this->generateRulePair($line, array_keys(self::TOP_LEVEL_DIRECTIVES))) !== false) {
return $this->handler->{self::TOP_LEVEL_DIRECTIVES[$pair[0]]}->add($pair[1]);
} | Add line
@param string $line
@return bool | entailment |
public function get( $key, $default = null ) {
$metadata = get_metadata( $this->meta_type, $this->object_id, $key, true );
return false !== $metadata ? $metadata : $default;
} | {@inheritdoc} | entailment |
public function set( $key, $value ) {
return (bool) update_metadata( $this->meta_type, $this->object_id, $key, $value );
} | {@inheritdoc} | entailment |
public function accessOverride()
{
if (strpos($this->scheme, 'http') === 0) {
switch (floor($this->code / 100) * 100) {
case 300:
case 400:
return self::DIRECTIVE_ALLOW;
case 500:
return self::DIRECTIVE_DISAL... | Check if the code overrides the robots.txt file
@link https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt#handling-http-result-codes
@link https://yandex.com/support/webmaster/controlling-robot/robots-txt.xml#additional-info
@return string|false | entailment |
public function initialize() {
static::initialize_registry();
$this->prepare_form_data();
$this->make_fields_validation();
Dependency::check( $this->fields->all(), $this->data );
if ( $error_name = $this->config->get_option( 'resolve_errors' ) ) {
$this->resolve_flash_errors( $error_name );
}
if (... | {@inheritdoc} | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.