_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
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
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( (array) $data, true ); $object->_exists = true; if ( static::$_cache && ! static::is_data_cached( $pk ) ) { Cache::update( $object );
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,
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() );
php
{ "resource": "" }
q263504
Model.is_data_cached
test
protected static function is_data_cached( $pk ) { if ( ! static::$_cache )
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 ) );
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( 'exclude_relations' => array_filter( $this->get_all_relations(), function ( $attribute ) use ( $columns ) { return array_key_exists( $attribute, $columns ); } ) ) ); $this->fire_model_event( 'saving' );
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 );
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 ) ) {
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( 'creating' ); $columns = static::table()->get_columns(); $insert = array(); foreach ( $this->get_raw_attributes() as $attribute => $value ) { $insert[ $attribute ] = $columns[ $attribute ]->prepare_for_storage( $value ); } $insert_id = static::make_query_object()->insert( $insert ); if ( $insert_id ) { $this->set_raw_attribute( static::table()->get_primary_key(), $insert_id ); } $default_columns_to_fill = array(); foreach ( static::table()->get_columns() as $name => $column ) { if ( ! array_key_exists( $name, $this->get_raw_attributes() ) ) { $default_columns_to_fill[] = $name; } } if ( $default_columns_to_fill ) {
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 = static::table()->get_columns(); $previous = array(); $update = array(); foreach ( $dirty as $column => $value )
php
{ "resource": "" }
q263511
Model.finish_save
test
protected function finish_save() { $this->fire_model_event( 'saved' ); foreach ( $this->_relations as $attribute => $relation ) {
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(
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; $data[] = $model->get_raw_attributes(); } $rows = static::make_query_object()->insert_many( $data ); foreach ( $rows as $i
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";
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 )
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[
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 )
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
php
{ "resource": "" }
q263519
Model.with
test
public static function with( $relations ) { $query = FluentQuery::from_model(
php
{ "resource": "" }
q263520
Model.to_array
test
public function to_array() { $attributes = array(); foreach ( static::table()->get_columns() as $attribute => $column ) {
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)";
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.
php
{ "resource": "" }
q263523
Simple_Query.get
test
public function get( $row_key, $columns = '*' ) { return
php
{ "resource": "" }
q263524
Simple_Query.get_column
test
public function get_column( $column, $row_key ) { return $this->get_column_by( $column,
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 ] ) ) { throw new InvalidColumnException( "Invalid column." ); } $select->also( "`$col`" ); } } elseif ( $columns == Select::ALL ) { $select = new Select( $columns ); } else { if ( ! isset( $allowed_columns[ $columns ] ) ) { throw new InvalidColumnException( "Invalid column" ); }
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 => $value ) { if ( ! isset( $where ) ) { $where =
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 ) { if ( $val === null ) { $null_columns[] = $col; }
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, $columns ); foreach ( $data as $name => $value ) { $data[ $name ] = $this->prepare_for_storage( $name, $value ); } $formats = array_fill( 0, count( $data ), '%s' );
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->get_primary_key() => $row_key
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(
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 {
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_id, $term->taxonomy, array( 'name' => wp_slash( $term->name ), 'description' => wp_slash( $term->description ), 'parent' => $term->parent, 'slug' => $term->slug ) ); } if ( is_wp_error( $ids ) ) { throw
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 (
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,
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
php
{ "resource": "" }
q263536
QueryBuilder.set
test
public function set($nameParams, $val) { $this->_setName[] = $nameParams;
php
{ "resource": "" }
q263537
QueryBuilder.select
test
public function select($field) { $this->_queryType = self :: SELECT; if (!is_array($field)) {
php
{ "resource": "" }
q263538
QueryBuilder.resetSelect
test
public function resetSelect($field = null) { $this->_select = array(); if ($field !== null) {
php
{ "resource": "" }
q263539
QueryBuilder.update
test
public function update($tableName) { $this->_queryType = self :: UPDATE;
php
{ "resource": "" }
q263540
QueryBuilder.delete
test
public function delete($tableName) { $this->_queryType = self :: DELETE;
php
{ "resource": "" }
q263541
QueryBuilder.insertInto
test
public function insertInto($tableName) { $this->_queryType = self :: INSERT;
php
{ "resource": "" }
q263542
QueryBuilder.from
test
public function from($tableName, $aliasTable = null) { $this->_from = sprintf('%s %s',
php
{ "resource": "" }
q263543
QueryBuilder.join
test
public function join($mode, $table, $on) { $this->_join[] = sprintf('%s JOIN %s
php
{ "resource": "" }
q263544
QueryBuilder.andWhere
test
public function andWhere($field, $comparisonOperator, $value) {
php
{ "resource": "" }
q263545
QueryBuilder.orWhere
test
public function orWhere($field, $comparisonOperator, $value) {
php
{ "resource": "" }
q263546
QueryBuilder.resetOrderBy
test
public function resetOrderBy($orderName = null, $orderVal = '') { $this->_orderBy = array(); if ($orderName !== null) {
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 {
php
{ "resource": "" }
q263548
QueryBuilder.resetLimit
test
public function resetLimit($limitStart = null, $limitEnd = null) { $this->_limit = ''; if ($limitStart !== null) {
php
{ "resource": "" }
q263549
TrashSupport.boot_TrashSupport
test
public static function boot_TrashSupport() { $table = static::table(); if ( ! $table instanceof TrashTable ) { throw new \UnexpectedValueException( sprintf( "%s
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();
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(
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;
php
{ "resource": "" }
q263553
Relation.cache_results
test
protected function cache_results( $results, Model $model ) { if ( $results instanceof Collection ) { $this->cache_collection( $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(
php
{ "resource": "" }
q263555
Relation.cache_single
test
protected function cache_single( $result, Model $model ) { $id = $this->saver->get_pk( $result );
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;
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_error( $id ) ) { throw
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
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' => $this->isDebug(), 'app.charset' => $this->getCharset(), 'app.path' => $this->getAppPath(), 'app.config_path' => $this->getConfigPath(), 'app.base_path' => $this->getBasePath(),
php
{ "resource": "" }
q263560
Kernel.containerIsCacheable
test
public function containerIsCacheable(): bool { $result = true; // container is cacheable by default if ($this->container->hasParameter('container.cache')) { $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->compile(true); } else { $filename = $this->getContainerCacheFilename(); if (file_exists($filename)) { require_once($filename); $this->setContainer(new CachedContainer()); } else {
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')) { $loader->load($environment . '.yml'); }
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
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' => $this->other_attribute ) ); $pk = $this->saver->get_pk( $saved ); if ( $new && $pk ) { $added[ $pk ]
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 ) { unset( $cached[ $i ] ); } $remove_where = new Where( $this->other_column, true, esc_sql( $this->parent->get_pk() ) ); $remove_where->qAnd(
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 ( $pk ) { $insert[] = "({$parent},{$pk})"; $cached[] = $pk; } }
php
{ "resource": "" }
q263567
APIRepository.create
test
public function create($attributes) { if (!isset($attributes['uuid']))
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); if (!$user) { return null; } // populate Guard with the $user $auth->setUser($user); // the purpose of this function is to look up the secret $api_secret = $user->getApiSecretKey(); return $api_secret;
php
{ "resource": "" }
q263569
BaseRepository.create
test
public function create($attributes) { $attributes = $this->modifyAttributesBeforeCreate($attributes); $model = $this->prototype_model->create($attributes); // broadcast create event
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"); $result = $this->buildResult($asset, $dotPos, ($this->cacheSuffix === true) ? $assetFilemtime : null);
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
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_SEPARATOR . 'cache' : false, ]); $parser->parseFile($basePath . DIRECTORY_SEPARATOR . $asset);
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' => http_build_query($options), ]
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' => ['earliestGet' => $this->calculateEarliestGet($options['runningResetDuration'])]]; $end = $this->calculateEndTime($options['waitDurationInMillis']); $sleepTime = $this->calculateSleepTime($options['pollDurationInMillis']); $messages = new ArrayObject();
php
{ "resource": "" }
q263575
AbstractQueue.count
test
final public function count(array $query, bool $running = null) : int { $totalQuery = []; if ($running === true || $running === false) {
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(),
php
{ "resource": "" }
q263577
AbstractQueue.send
test
final public function send(Message $message) { $document = [ '_id' => $message->getId(), 'payload' => $message->getPayload(), 'earliestGet' => $message->getEarliestGet(),
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
php
{ "resource": "" }
q263579
Issues.add
test
public function add(string $type, string $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'); }
php
{ "resource": "" }
q263581
Issues.import
test
public function import(self $issues) { foreach ($issues->types() as $type) { $source = $issues->messages($type); $destination = $this->messages($type);
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(sprintf('Identifier "%s" is not defined.', $id)); } if ( isset($this->raw[$id]) || !is_object($this->values[$id]) || isset($this->protected[$this->values[$id]]) || !method_exists($this->values[$id], '__invoke') ) {
php
{ "resource": "" }
q263583
Container.offsetExists
test
public function offsetExists($id) { if ($this->hasAlias($id)) { $id = $this->getAlias($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 \InvalidArgumentException(sprintf('Identifier "%s" does not contain an object definition.', $id)); } if ( ! is_object($callable) || ! method_exists($callable, '__invoke')) { throw new \InvalidArgumentException('Extension service definition is not a Closure or invokable object.'); } $factory = $this->values[$id];
php
{ "resource": "" }
q263585
Container.register
test
public function register(ServiceProviderInterface $provider, array $values = []) { $provider->register($this);
php
{ "resource": "" }
q263586
Container.tag
test
public function tag($id, $tag) { if ( ! isset($this->serviceTags[$id])) {
php
{ "resource": "" }
q263587
Container.findTaggedServiceIds
test
public function findTaggedServiceIds($tag) { $ids = []; foreach ($this->serviceTags as $id => $tags) { if
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) {
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])) { throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name)); } $this->bundles[$name] = $bundle; if ($parentName = $bundle->getParent()) { if (isset($directChildren[$parentName])) { throw new \LogicException(sprintf('Bundle "%s" is directly extended by two bundles "%s" and "%s".', $parentName, $name, $directChildren[$parentName])); } if ($parentName == $name) { throw new \LogicException(sprintf('Bundle "%s" can not extend itself.', $name)); } $directChildren[$parentName] = $name; } else { $topMostBundles[$name] = $bundle; } } // look for orphans
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, 'kernel.environment' => $this->environment, 'kernel.debug' => $this->debug, 'kernel.name' => $this->name,
php
{ "resource": "" }
q263591
SchemasValidator.validate
test
public function validate(string $content) { if ($this->hasRetriever()) { $this->validateWithRetriever($content); } else
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 $schemas = $validator->buildSchemas(); // replace with the local path foreach ($schemas as $schema) { /** @var \XmlSchemaValidator\Schema $schema */ $location = $schema->getLocation(); $localPath =
php
{ "resource": "" }
q263593
SchemasValidator.validateWithoutRetriever
test
public function validateWithoutRetriever($content) { // create the schema validator object $validator = new SchemaValidator($content); if (! $validator->validate()) {
php
{ "resource": "" }
q263594
AssetManager.container
test
public function container($name = 'default') { if (isset($this->containers[$name])) {
php
{ "resource": "" }
q263595
AssetManager.outputJs
test
public function outputJs($container = 'default') { $assets = $this->getAssets($container, 'js'); $html = []; foreach ($assets as $asset) {
php
{ "resource": "" }
q263596
AssetManager.outputCss
test
public function outputCss($container = 'default') { $assets = $this->getAssets($container, 'css'); $html = []; foreach ($assets as $asset) {
php
{ "resource": "" }
q263597
AssetManager.getAssets
test
protected function getAssets($container, $type) { if ( ! isset($this->containers[$container])) { return []; } $container = $this->containers[$container];
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) {
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": "" }