_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q263500 | Model.get_dirty | test | public function get_dirty() {
$dirty = array();
foreach ( $this->get_raw_attributes() as $key => $value ) {
if ( ! array_key_exists( $key, $this->_original ) ) {
$dirty[ $key ] = $value;
} elseif ( $value !== $this->_original[ $key ] && ! $this->original_is_numerically_equivalent( $key ) ) {
$dirty[ ... | php | {
"resource": ""
} |
q263501 | Model.get | test | public static function get( $pk ) {
if ( ! $pk ) {
return null;
}
if ( ! is_scalar( $pk ) ) {
throw new \InvalidArgumentException( 'Primary key must be scalar.' );
}
$data = static::get_data_from_pk( $pk );
if ( $data ) {
$object = new static( new \stdClass() );
$object->set_raw_attributes(... | php | {
"resource": ""
} |
q263502 | Model.from_query | test | public static function from_query( array $attributes = array() ) {
$instance = new static( new \stdClass() );
$instance->set_raw_attributes( $attributes, true );
$instance->_exists = true;
if ( static::$_cache && ! static::is_data_cached( $instance->get_pk() ) ) {
Cache::update( $instance );
}
return ... | php | {
"resource": ""
} |
q263503 | Model.get_data_from_pk | test | protected static function get_data_from_pk( $pk ) {
$data = static::$_cache ? Cache::get( $pk, static::get_cache_group() ) : null;
if ( ! $data ) {
$query = new FluentQuery( static::table() );
$data = $query->where( static::table()->get_primary_key(), '=', $pk )->first();
}
return $data ? (object) $da... | php | {
"resource": ""
} |
q263504 | Model.is_data_cached | test | protected static function is_data_cached( $pk ) {
if ( ! static::$_cache ) {
return false;
}
$data = Cache::get( $pk, static::get_cache_group() );
return ! empty( $data );
} | php | {
"resource": ""
} |
q263505 | Model.update | test | protected function update( $key, $value ) {
$columns = static::table()->get_columns();
$data = array(
$key => $columns[ $key ]->prepare_for_storage( $value )
);
$res = static::make_query_object()->update( $this->get_pk(), $data );
if ( $res && static::$_cache ) {
Cache::update( $this );
}
retur... | php | {
"resource": ""
} |
q263506 | Model.save | test | public function save( array $options = array() ) {
if ( isset( $options['exclude_relations'] ) && ! is_array( $options['exclude_relations'] ) ) {
$options['exclude_relations'] = (array) $options['exclude_relations'];
}
$columns = static::table()->get_columns();
$options = wp_parse_args( $options, array(
... | php | {
"resource": ""
} |
q263507 | Model.save_has_foreign_relations | test | protected function save_has_foreign_relations() {
foreach ( $this->_relations as $attribute => $value ) {
$relation = $this->get_relation( $attribute );
if ( $relation instanceof HasForeign && $value ) {
$value = $relation->persist( $value );
$pk = $relation->get_pk_for_value( $value );
$this... | php | {
"resource": ""
} |
q263508 | Model.save_loaded_relations | test | protected function save_loaded_relations( array $exclude = array() ) {
foreach ( $this->_relations as $relation => $values ) {
if ( in_array( $relation, $exclude ) ) {
continue;
}
$relation_controller = $this->get_relation( $relation );
$relation_controller->persist( $values );
}
} | php | {
"resource": ""
} |
q263509 | Model.do_save_as_insert | test | protected function do_save_as_insert() {
if ( static::table() instanceof TimestampedTable ) {
$time = $this->fresh_timestamp();
$this->set_attribute( static::table()->get_created_at_column(), $time );
$this->set_attribute( static::table()->get_updated_at_column(), $time );
}
$this->fire_model_event( '... | php | {
"resource": ""
} |
q263510 | Model.do_save_as_update | test | protected function do_save_as_update() {
$dirty = $this->get_dirty();
if ( ! $dirty ) {
return true;
}
if ( static::table() instanceof TimestampedTable ) {
$this->set_attribute( static::table()->get_updated_at_column(), $this->fresh_timestamp() );
$dirty = $this->get_dirty();
}
$columns = stati... | php | {
"resource": ""
} |
q263511 | Model.finish_save | test | protected function finish_save() {
$this->fire_model_event( 'saved' );
foreach ( $this->_relations as $attribute => $relation ) {
if ( $relation instanceof Collection ) {
$relation->clear_memory();
}
}
$this->sync_original();
} | php | {
"resource": ""
} |
q263512 | Model.delete | test | public function delete() {
$this->fire_model_event( 'deleting' );
foreach ( $this->get_all_relations() as $relation ) {
$this->get_relation( $relation )->on_delete( $this );
}
static::make_query_object()->delete( $this->get_pk() );
if ( static::$_cache ) {
Cache::delete( $this );
}
$this->_exis... | php | {
"resource": ""
} |
q263513 | Model.create_many | test | public static function create_many( array $to_insert ) {
$models = array();
$data = array();
foreach ( $to_insert as $model ) {
$model = $model instanceof static ? $model : new static ( $model );
$model->fire_model_event( 'saving' );
$model->fire_model_event( 'creating' );
$models[] = $model;
... | php | {
"resource": ""
} |
q263514 | Model.fire_model_event | test | protected function fire_model_event( $event, $arguments = array() ) {
if ( ! static::$_event_dispatcher ) {
return;
}
$event = static::table()->get_slug() . ".$event";
static::$_event_dispatcher->dispatch( $event, new GenericEvent( $this, $arguments ) );
} | php | {
"resource": ""
} |
q263515 | Model.register_model_event | test | public static function register_model_event( $event, $callback, $priority = 10, $accepted_args = 3 ) {
if ( isset( static::$_event_dispatcher ) ) {
$event = static::table()->get_slug() . ".$event";
static::$_event_dispatcher->add_listener( $event, $callback, $priority, $accepted_args );
}
} | php | {
"resource": ""
} |
q263516 | Model.get_data_to_cache | test | public function get_data_to_cache() {
$data = $this->get_raw_attributes();
$columns = static::table()->get_columns();
foreach ( $data as $column => $value ) {
if ( isset( $columns[ $column ] ) ) {
$data[ $column ] = $columns[ $column ]->prepare_for_storage( $value );
}
}
return $data;
} | php | {
"resource": ""
} |
q263517 | Model.register_global_scope | test | public static function register_global_scope( $scope_or_identifier, Closure $closure = null ) {
if ( $scope_or_identifier instanceof Scope ) {
self::$_scopes[ get_called_class() ][ get_class( $scope_or_identifier ) ] = $scope_or_identifier;
} elseif ( is_string( $scope_or_identifier ) && $closure ) {
self::$... | php | {
"resource": ""
} |
q263518 | Model.without_global_scopes | test | public static function without_global_scopes( array $scopes ) {
$query = static::query_with_no_global_scopes();
foreach ( static::get_global_scopes() as $id => $scope ) {
if ( in_array( $id, $scopes ) ) {
continue;
}
if ( $scope instanceof Scope ) {
$scope->apply( $query );
} else {
$sco... | php | {
"resource": ""
} |
q263519 | Model.with | test | public static function with( $relations ) {
$query = FluentQuery::from_model( get_called_class() );
call_user_func_array( array( $query, 'with' ), func_get_args() );
return $query;
} | php | {
"resource": ""
} |
q263520 | Model.to_array | test | public function to_array() {
$attributes = array();
foreach ( static::table()->get_columns() as $attribute => $column ) {
$attributes[ $attribute ] = $this->get_attribute( $attribute );
}
return $attributes;
} | php | {
"resource": ""
} |
q263521 | Where.get_comparison | test | protected function get_comparison() {
if ( ! $this->column ) {
return '';
}
$query = "{$this->column} ";
if ( is_array( $this->value ) ) {
$values = $this->implode( $this->value );
if ( $this->operator ) {
$query .= "IN ($values)";
} else {
$query .= "NOT IN ($values)";
}
} elseif (... | php | {
"resource": ""
} |
q263522 | Where.get_value | test | protected function get_value() {
$query = $this->for_clause ? '(' : $this->get_comparison();
if ( ! empty( $this->clauses ) ) {
foreach ( $this->clauses as $i => $clause ) {
// We don't want to add the connector if this is the first clause and there is no comparison.
if ( strlen( $query ) > 1 ) {
... | php | {
"resource": ""
} |
q263523 | Simple_Query.get | test | public function get( $row_key, $columns = '*' ) {
return $this->get_by( $this->table->get_primary_key(), $row_key, $columns );
} | php | {
"resource": ""
} |
q263524 | Simple_Query.get_column | test | public function get_column( $column, $row_key ) {
return $this->get_column_by( $column, $this->table->get_primary_key(), $row_key );
} | php | {
"resource": ""
} |
q263525 | Simple_Query.get_by_or_many_by_helper | test | protected function get_by_or_many_by_helper( $column, $value, $columns = '*', $method ) {
$builder = new Builder();
$allowed_columns = $this->table->get_columns();
if ( is_array( $columns ) ) {
$select = new Select( null );
foreach ( $columns as $col ) {
if ( ! isset( $allowed_columns[ $col ] ) ) ... | php | {
"resource": ""
} |
q263526 | Simple_Query.count | test | public function count( $wheres = array() ) {
$builder = new Builder();
$select = new Select( null );
$select->expression( 'COUNT', '*' );
$builder->append( $select );
$builder->append( new From( $this->table->get_table_name( $this->wpdb ) ) );
if ( ! empty( $wheres ) ) {
foreach ( $wheres as $column... | php | {
"resource": ""
} |
q263527 | Simple_Query.insert | test | public function insert( $data ) {
// Set default values
$data = wp_parse_args( $data, $this->table->get_column_defaults() );
$columns = $this->table->get_columns();
// White list columns
$data = array_intersect_key( $data, $columns );
$null_columns = array();
foreach ( $data as $col => $val ) {
i... | php | {
"resource": ""
} |
q263528 | Simple_Query.update | test | public function update( $row_key, $data, $where = array() ) {
if ( empty( $row_key ) ) {
return false;
}
if ( empty( $where ) ) {
$where = array( $this->table->get_primary_key() => $row_key );
}
$columns = $this->table->get_columns();
// White list columns
$data = array_intersect_key( $data, $co... | php | {
"resource": ""
} |
q263529 | Simple_Query.delete | test | public function delete( $row_key ) {
if ( empty( $row_key ) ) {
return false;
}
$row_key = $this->escape_value( $this->table->get_primary_key(), $row_key );
$prev = $this->wpdb->show_errors( false );
$result = $this->wpdb->delete( $this->table->get_table_name( $this->wpdb ), array(
$this->table->ge... | php | {
"resource": ""
} |
q263530 | Simple_Query.delete_many | test | public function delete_many( $wheres ) {
$format = array_fill( 0, count( $wheres ), '%s' );
$prev = $this->wpdb->show_errors( false );
$result = $this->wpdb->delete( $this->table->get_table_name( $this->wpdb ), $wheres, $format );
$this->wpdb->show_errors( $prev );
if ( $this->wpdb->last_error ) {
thro... | php | {
"resource": ""
} |
q263531 | Simple_Query.generate_exception_from_db_error | test | protected function generate_exception_from_db_error() {
if ( ! $this->wpdb->last_error ) {
return null;
}
if ( $this->is_mysqli() ) {
$error_number = mysqli_errno( $this->get_dbh() );
} else {
$error_number = mysql_errno( $this->get_dbh() );
}
return new Exception( $this->wpdb->last_error, $erro... | php | {
"resource": ""
} |
q263532 | TermSaver.do_save | test | protected function do_save( $term ) {
if ( ! $term->term_id ) {
$ids = wp_insert_term( wp_slash( $term->name ), $term->taxonomy, array(
'description' => wp_slash( $term->description ),
'parent' => $term->parent,
'slug' => $term->slug
) );
} else {
$ids = wp_update_term( $term->term... | php | {
"resource": ""
} |
q263533 | HasForeign.make_query_object | test | protected function make_query_object( $model_class = false ) {
$query = call_user_func( array( $this->related_model, 'query_with_no_global_scopes' ) );
if ( ! $model_class ) {
$query->set_model_class( null );
}
return $query;
} | php | {
"resource": ""
} |
q263534 | HasForeign.fetch_results_for_eager_load | test | protected function fetch_results_for_eager_load( $primary_keys ) {
if ( ! $primary_keys ) {
return new Collection( array(), false, $this->saver );
}
$query = $this->make_query_object( true );
$query->where( $this->related_primary_key_column, true, $primary_keys );
return $query->results( $this->saver );... | php | {
"resource": ""
} |
q263535 | QueryBuilder.newValues | test | public function newValues($nameParams, $val)
{
// store value buffer data
if (count($this->_lastInsertValues) > 0) {
$this->_insertValues[] = $this->_lastInsertValues;
}
// set new value in insert buffer
$this->_lastInsertValues = array($nameParams => $val);
... | php | {
"resource": ""
} |
q263536 | QueryBuilder.set | test | public function set($nameParams, $val)
{
$this->_setName[] = $nameParams;
$this->_setVal[] = $val;
return $this;
} | php | {
"resource": ""
} |
q263537 | QueryBuilder.select | test | public function select($field)
{
$this->_queryType = self :: SELECT;
if (!is_array($field)) {
$field = array($field);
}
$this->_select = array_merge($this->_select, $field);
return $this;
} | php | {
"resource": ""
} |
q263538 | QueryBuilder.resetSelect | test | public function resetSelect($field = null)
{
$this->_select = array();
if ($field !== null) {
$this->select($field);
}
return $this;
} | php | {
"resource": ""
} |
q263539 | QueryBuilder.update | test | public function update($tableName)
{
$this->_queryType = self :: UPDATE;
$this->_update = $tableName;
return $this;
} | php | {
"resource": ""
} |
q263540 | QueryBuilder.delete | test | public function delete($tableName)
{
$this->_queryType = self :: DELETE;
$this->_delete = $tableName;
return $this;
} | php | {
"resource": ""
} |
q263541 | QueryBuilder.insertInto | test | public function insertInto($tableName)
{
$this->_queryType = self :: INSERT;
$this->_insert = $tableName;
return $this;
} | php | {
"resource": ""
} |
q263542 | QueryBuilder.from | test | public function from($tableName, $aliasTable = null)
{
$this->_from = sprintf('%s %s', $tableName, $aliasTable);
return $this;
} | php | {
"resource": ""
} |
q263543 | QueryBuilder.join | test | public function join($mode, $table, $on)
{
$this->_join[] = sprintf('%s JOIN %s ON %s', $mode, $table, $on);
return $this;
} | php | {
"resource": ""
} |
q263544 | QueryBuilder.andWhere | test | public function andWhere($field, $comparisonOperator, $value)
{
$this->where($field, $comparisonOperator, $value, 'AND');
return $this;
} | php | {
"resource": ""
} |
q263545 | QueryBuilder.orWhere | test | public function orWhere($field, $comparisonOperator, $value)
{
$this->where($field, $comparisonOperator, $value, 'OR');
return $this;
} | php | {
"resource": ""
} |
q263546 | QueryBuilder.resetOrderBy | test | public function resetOrderBy($orderName = null, $orderVal = '')
{
$this->_orderBy = array();
if ($orderName !== null) {
$this->orderBy($orderName, $orderVal);
}
return $this;
} | php | {
"resource": ""
} |
q263547 | QueryBuilder.limit | test | public function limit($limitStart = null, $limitEnd = null)
{
if ($limitStart === null) {
return $this;
}
if ($limitEnd === null) {
$this->_limit = sprintf('LIMIT %d', $limitStart);
} else {
$this->_limit = sprintf('LIMIT %d, %d', $limitStart, $li... | php | {
"resource": ""
} |
q263548 | QueryBuilder.resetLimit | test | public function resetLimit($limitStart = null, $limitEnd = null)
{
$this->_limit = '';
if ($limitStart !== null) {
$this->limit($limitStart, $limitEnd);
}
return $this;
} | php | {
"resource": ""
} |
q263549 | TrashSupport.boot_TrashSupport | test | public static function boot_TrashSupport() {
$table = static::table();
if ( ! $table instanceof TrashTable ) {
throw new \UnexpectedValueException( sprintf( "%s model's table must implement TrashTable." ), get_called_class() );
}
static::register_global_scope( 'trash', function ( FluentQuery $query ) use ... | php | {
"resource": ""
} |
q263550 | Relation.get_results | test | public function get_results() {
if ( ( $results = $this->load_from_cache( $this->parent ) ) === null ) {
$results = $this->fetch_results();
if ( $this->cache ) {
$this->cache_results( $results, $this->parent );
$this->maybe_register_cache_events();
}
}
if ( $this->keep_synced && $results insta... | php | {
"resource": ""
} |
q263551 | Relation.load_from_cache | test | protected function load_from_cache( Model $model ) {
$cached = wp_cache_get( $model->get_pk(), $this->get_cache_group() );
if ( $cached === false ) {
return null;
}
if ( is_array( $cached ) ) {
return $this->load_collection_from_cache( $cached, $model );
} else {
return $this->load_single_from_cac... | php | {
"resource": ""
} |
q263552 | Relation.load_collection_from_cache | test | protected function load_collection_from_cache( array $cached, Model $for ) {
$models = array();
$removed = array();
foreach ( $cached as $id ) {
$model = $this->saver->get_model( $id );
if ( $model ) {
$models[ $id ] = $model;
} else {
$removed[] = $id;
}
}
$diff = array_diff( $cached... | php | {
"resource": ""
} |
q263553 | Relation.cache_results | test | protected function cache_results( $results, Model $model ) {
if ( $results instanceof Collection ) {
$this->cache_collection( $results, $model );
} elseif ( is_object( $results ) ) {
$this->cache_single( $results, $model );
}
} | php | {
"resource": ""
} |
q263554 | Relation.cache_collection | test | protected function cache_collection( Collection $collection, Model $model ) {
$ids = array_map( function ( $e ) use ( $collection ) {
return $collection->get_saver()->get_pk( $e );
}, $collection->toArray() );
wp_cache_set( $model->get_pk(), $ids, $this->get_cache_group() );
} | php | {
"resource": ""
} |
q263555 | Relation.cache_single | test | protected function cache_single( $result, Model $model ) {
$id = $this->saver->get_pk( $result );
wp_cache_set( $model->get_pk(), $id, $this->get_cache_group() );
} | php | {
"resource": ""
} |
q263556 | Relation.maybe_register_cache_events | test | private function maybe_register_cache_events() {
$key = get_class( $this );
$key .= "-{$this->attribute}";
if ( isset( $this->registered_cache_events[ $key ] ) ) {
return;
}
$this->register_cache_events();
$this->registered_cache_events[ $key ] = true;
} | php | {
"resource": ""
} |
q263557 | UserSaver.do_save | test | protected function do_save( \WP_User $user ) {
if ( ! $user->exists() ) {
if ( empty( $user->user_pass ) ) {
$user->user_pass = wp_generate_password( 24 );
}
$id = wp_insert_user( wp_slash( $user->to_array() ) );
} else {
$id = wp_update_user( wp_slash( $user->to_array() ) );
}
if ( is_wp_er... | php | {
"resource": ""
} |
q263558 | ModelWithMeta.set_last_updated_at | test | private function set_last_updated_at() {
if ( ! static::get_table() instanceof TimestampedTable ) {
return;
}
$dirty = $this->is_dirty();
$this->set_attribute( static::get_table()->get_updated_at_column(), $this->fresh_timestamp() );
// If the model is dirty, we don't want to commit our save since the ... | php | {
"resource": ""
} |
q263559 | Kernel.getContainerParameters | test | public function getContainerParameters(): array
{
$result = array(
'app.name' => $this->getName(),
'app.version' => $this->getVersion(),
'app.environment' => $this->getEnvironment(),
'app.sub_environment' => $this->getSubEnvironment(),
'app.debug' ... | php | {
"resource": ""
} |
q263560 | Kernel.containerIsCacheable | test | public function containerIsCacheable(): bool
{
$result = true; // container is cacheable by default
if ($this->container->hasParameter('container.cache')) {
$result = (bool)$this->container->getParameter('container.cache');
}
return $result;
} | php | {
"resource": ""
} |
q263561 | Kernel.boot | test | protected function boot()
{
if ($this->hasBooted()) return; // Nothing to do
if ($this->debug) {
$this->setContainer(new ContainerBuilder(new EnvPlaceholderParameterBag($this->getContainerParameters())));
$this->loadContainerConfiguration();
$this->container->com... | php | {
"resource": ""
} |
q263562 | Kernel.loadContainerConfiguration | test | protected function loadContainerConfiguration()
{
$configPath = $this->getConfigPath();
$environment = $this->getEnvironment();
$loader = new YamlFileLoader($this->container, new FileLocator($configPath));
if (file_exists($configPath . '/' . $environment . '.yml')) {
$l... | php | {
"resource": ""
} |
q263563 | BaseTable.build_column_name_for_table | test | protected function build_column_name_for_table( Table $table ) {
$basename = $this->class_basename( $table );
$tableized = Inflector::tableize( $basename );
$parts = explode( '_', $tableized );
$last_plural = array_pop( $parts );
$last_singular = Inflector::singularize( $last_plural );
$parts[]... | php | {
"resource": ""
} |
q263564 | ManyToMany.persist_do_save | test | protected function persist_do_save( Collection $values ) {
$added = array();
foreach ( $values as $value ) {
$new = ! $this->saver->get_pk( $value );
// prevent recursion by excluding the relation that references this from being saved.
$saved = $this->saver->save( $value, array( 'exclude_relations' => ... | php | {
"resource": ""
} |
q263565 | ManyToMany.persist_removed | test | protected function persist_removed( $removed ) {
$cached = wp_cache_get( $this->parent->get_pk(), $this->get_cache_group() ) ?: array();
global $wpdb;
$where = new Where( 1, false, 1 );
foreach ( $removed as $model ) {
$i = array_search( $this->saver->get_pk( $model ), $cached );
if ( $i !== false )... | php | {
"resource": ""
} |
q263566 | ManyToMany.persist_added | test | protected function persist_added( $added ) {
$cached = wp_cache_get( $this->parent->get_pk(), $this->get_cache_group() ) ?: array();
global $wpdb;
$insert = array();
$parent = esc_sql( $this->parent->get_pk() );
foreach ( $added as $model ) {
$pk = esc_sql( $this->saver->get_pk( $model ) );
if ( $... | php | {
"resource": ""
} |
q263567 | APIRepository.create | test | public function create($attributes) {
if (!isset($attributes['uuid'])) { $attributes['uuid'] = Uuid::uuid4()->toString(); }
return parent::create($attributes);
} | php | {
"resource": ""
} |
q263568 | AuthenticateProtectedAPIRequest.initAuthenticator | test | protected function initAuthenticator() {
$auth = $this->auth;
$this->hmac_validator = new \Tokenly\HmacAuth\Validator(function($api_token) use ($auth) {
// lookup the API secrect by $api_token using $this->auth
$user = $this->user_repository->findByAPIToken($api_token);
... | php | {
"resource": ""
} |
q263569 | BaseRepository.create | test | public function create($attributes) {
$attributes = $this->modifyAttributesBeforeCreate($attributes);
$model = $this->prototype_model->create($attributes);
// broadcast create event
if ($this->usesTrait(BroadcastsRepositoryEvents::class)) {
$this->broadcastRepositoryEvent(n... | php | {
"resource": ""
} |
q263570 | AssetConverter.convert | test | public function convert($asset, $basePath)
{
if (($dotPos = strrpos($asset, '.')) === false)
return $asset;
if (($ext = substr($asset, $dotPos + 1)) !== self::INPUT_EXT)
return parent::convert($asset, $basePath);
$assetFilemtime = @filemtime("$basePath/$asset");
... | php | {
"resource": ""
} |
q263571 | AssetConverter.buildResult | test | protected function buildResult($asset, $dotPos = null, $resultSuffix = null)
{
if ($dotPos === null) {
if (($dotPos = strrpos($asset, '.')) === false) {
return $asset;
}
}
$divider = ($this->compress === true) ? '-m' : '-';
$suffix = ($resultS... | php | {
"resource": ""
} |
q263572 | AssetConverter.parseLess | test | protected function parseLess($basePath, $asset, $result)
{
$parser = new \Less_Parser([
'compress' => ($this->compress === true) ? true : false,
'cache_dir' => ($this->useCache === true) ? ($this->cacheDir !== null && is_dir($this->cacheDir)) ? $this->cacheDir : __DIR__ . DIRECTORY_S... | php | {
"resource": ""
} |
q263573 | Pushover.send | test | public function send( $message, array $options = [] ) {
$options[Options::TOKEN] = $this->token;
$options[Options::USER] = $this->user;
$options[Options::MESSAGE] = $message;
$opts = [ 'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => ht... | php | {
"resource": ""
} |
q263574 | AbstractQueue.get | test | final public function get(array $query, array $options = []) : array
{
$completeQuery = $this->buildPayloadQuery(
['earliestGet' => ['$lte' => new UTCDateTime((int)(microtime(true) * 1000))]],
$query
);
$options += self::DEFAULT_GET_OPTIONS;
$update = ['$set'... | php | {
"resource": ""
} |
q263575 | AbstractQueue.count | test | final public function count(array $query, bool $running = null) : int
{
$totalQuery = [];
if ($running === true || $running === false) {
$key = $running ? '$gt' : '$lte';
$totalQuery['earliestGet'] = [$key => new UTCDateTime((int)(microtime(true) * 1000))];
}
... | php | {
"resource": ""
} |
q263576 | AbstractQueue.requeue | test | final public function requeue(Message $message)
{
$set = [
'payload' => $message->getPayload(),
'earliestGet' => $message->getEarliestGet(),
'priority' => $message->getPriority(),
'created' => new UTCDateTime(),
];
$this->collection->updateOne... | php | {
"resource": ""
} |
q263577 | AbstractQueue.send | test | final public function send(Message $message)
{
$document = [
'_id' => $message->getId(),
'payload' => $message->getPayload(),
'earliestGet' => $message->getEarliestGet(),
'priority' => $message->getPriority(),
'created' => new UTCDateTime(),
... | php | {
"resource": ""
} |
q263578 | AbstractQueue.verifySort | test | final private function verifySort(array $sort, string $label, array &$completeFields)
{
foreach ($sort as $key => $value) {
$this->throwIfTrue(!is_string($key), "key in \${$label} was not a string");
$this->throwIfTrue(
$value !== 1 && $value !== -1,
"... | php | {
"resource": ""
} |
q263579 | Issues.add | test | public function add(string $type, string $message)
{
$this->messages($type)->add($message);
} | php | {
"resource": ""
} |
q263580 | Issues.messages | test | public function messages(string $type)
{
if ('' === $type) {
throw new \InvalidArgumentException('The type of messages must be a non-empty string');
}
if (! array_key_exists($type, $this->messages)) {
$this->messages[$type] = new Messages();
}
return $... | php | {
"resource": ""
} |
q263581 | Issues.import | test | public function import(self $issues)
{
foreach ($issues->types() as $type) {
$source = $issues->messages($type);
$destination = $this->messages($type);
foreach ($source as $message) {
$destination->add($message);
}
}
} | php | {
"resource": ""
} |
q263582 | Container.offsetGet | test | public function offsetGet($id)
{
if ($this->hasAlias($id)) {
$id = $this->getAlias($id);
}
if (!$this->has($id) && class_exists($id)) {
return $this->build($id);
}
if (!isset($this->keys[$id])) {
throw new \InvalidArgumentException(sprint... | php | {
"resource": ""
} |
q263583 | Container.offsetExists | test | public function offsetExists($id)
{
if ($this->hasAlias($id)) {
$id = $this->getAlias($id);
}
return isset($this->keys[$id]);
} | php | {
"resource": ""
} |
q263584 | Container.extend | test | public function extend($id, $callable)
{
if ( ! isset($this->keys[$id])) {
throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
}
if ( ! is_object($this->values[$id]) || ! method_exists($this->values[$id], '__invoke')) {
throw new \In... | php | {
"resource": ""
} |
q263585 | Container.register | test | public function register(ServiceProviderInterface $provider, array $values = [])
{
$provider->register($this);
foreach ($values as $key => $value) {
$this[$key] = $value;
}
return $this;
} | php | {
"resource": ""
} |
q263586 | Container.tag | test | public function tag($id, $tag)
{
if ( ! isset($this->serviceTags[$id])) {
$this->serviceTags[$id] = [];
}
$this->serviceTags[$id][] = $tag;
return $this;
} | php | {
"resource": ""
} |
q263587 | Container.findTaggedServiceIds | test | public function findTaggedServiceIds($tag)
{
$ids = [];
foreach ($this->serviceTags as $id => $tags) {
if (in_array($tag, $tags)) {
$ids[] = $id;
}
}
return $ids;
} | php | {
"resource": ""
} |
q263588 | Kernel.boot | test | public function boot()
{
if (true === $this->booted) {
return;
}
// init container
$this->initializeContainer();
// init bundles
$this->initializeBundles();
foreach ($this->getBundles() as $bundle) {
if ($bundle instanceof ContainerA... | php | {
"resource": ""
} |
q263589 | Kernel.initializeBundles | test | protected function initializeBundles()
{
// init bundles
$this->bundles = array();
$topMostBundles = array();
$directChildren = array();
foreach ($this->registerBundles() as $bundle) {
$name = $bundle->getName();
if (isset($this->bundles[$name])) {
... | php | {
"resource": ""
} |
q263590 | Kernel.getKernelParameters | test | protected function getKernelParameters()
{
$bundles = array();
foreach ($this->bundles as $name => $bundle) {
$bundles[$name] = get_class($bundle);
}
return array_merge(
array(
'kernel.root_dir' => $this->rootDir,
'kerne... | php | {
"resource": ""
} |
q263591 | SchemasValidator.validate | test | public function validate(string $content)
{
if ($this->hasRetriever()) {
$this->validateWithRetriever($content);
} else {
$this->validateWithoutRetriever($content);
}
} | php | {
"resource": ""
} |
q263592 | SchemasValidator.validateWithRetriever | test | public function validateWithRetriever(string $content)
{
// obtain the retriever, throw its own exception if non set
$retriever = $this->getRetriever();
// create the schema validator object
$validator = new SchemaValidator($content);
// obtain the list of schemas
$sc... | php | {
"resource": ""
} |
q263593 | SchemasValidator.validateWithoutRetriever | test | public function validateWithoutRetriever($content)
{
// create the schema validator object
$validator = new SchemaValidator($content);
if (! $validator->validate()) {
throw new \RuntimeException('XSD error found: ' . $validator->getLastError());
}
} | php | {
"resource": ""
} |
q263594 | AssetManager.container | test | public function container($name = 'default')
{
if (isset($this->containers[$name])) {
return $this->containers[$name];
}
return $this->containers[$name] = new AssetContainer($name);
} | php | {
"resource": ""
} |
q263595 | AssetManager.outputJs | test | public function outputJs($container = 'default')
{
$assets = $this->getAssets($container, 'js');
$html = [];
foreach ($assets as $asset) {
$source = $this->url ? $this->url->asset($asset['source']): $asset['source'];
$html[] = $this->html->script($source, $asset['at... | php | {
"resource": ""
} |
q263596 | AssetManager.outputCss | test | public function outputCss($container = 'default')
{
$assets = $this->getAssets($container, 'css');
$html = [];
foreach ($assets as $asset) {
$source = $this->url ? $this->url->asset($asset['source']): $asset['source'];
$html[] = $this->html->style($source, $asset['a... | php | {
"resource": ""
} |
q263597 | AssetManager.getAssets | test | protected function getAssets($container, $type)
{
if ( ! isset($this->containers[$container])) {
return [];
}
$container = $this->containers[$container];
if ( ! isset($container->assets[$type]) || 0 === count($container->assets[$type])) {
return [];
... | php | {
"resource": ""
} |
q263598 | AssetManager.arrange | test | protected function arrange(array $assets)
{
list($original, $sorted) = array($assets, []);
while (count($assets) > 0) {
foreach ($assets as $asset => $value) {
$this->evaluateAsset($asset, $value, $original, $sorted, $assets);
}
}
return $sor... | php | {
"resource": ""
} |
q263599 | AssetManager.dependencyIsValid | test | protected function dependencyIsValid($asset, $dependency, $original, $assets)
{
if ( ! isset($original[$dependency])) {
return false;
}
else if ($dependency === $asset) {
throw new SelfDependencyException(sprintf('Asset "%" is dependent on itself.', $asset));
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.