sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
private function consumeOnce(callable $callback = null)
{
$tweet = $this->streamClient->read();
if ($callback !== null) {
return call_user_func($callback, Tweet::fromArray($tweet));
}
return Tweet::fromArray($tweet);
}
|
Consume once from the stream
Can return a callable or not depending on the entry point
- consume()
- do($callable)
@param callable $callback
@return Tweet|mixed
|
entailment
|
public function post(
string $endpoint,
array $options
)
{
$this->streamBody = $this->client
->post($endpoint, $options)
->getBody();
}
|
API Post request
@param string $endpoint
@param array $options
@return mixed|\Psr\Http\Message\StreamInterface
|
entailment
|
public function read(): array
{
while (!$this->streamBody->eof()) {
$tweet = json_decode(
$this->readStreamLine($this->streamBody),
true
);
if (null !== $tweet) {
return $tweet;
}
}
}
|
Start reading the stream
@return array
|
entailment
|
public function getLabel()
{
if ($this->model->label != "") {
return $this->model->label;
}
return StringTools::wordifyStringByUpperCase($this->getName());
}
|
Returns a label that the hosting view can use in the HTML output.
@return string
|
entailment
|
final protected function setIndex($index)
{
$this->model->leafIndex = $index;
$this->model->updatePath();
// Signal to all or any sub leaves that need to recompute their own path now.
$this->leafPathChanged();
}
|
Sets a view index for subsequent renders.
@param $index
|
entailment
|
final public function leafPathChanged()
{
foreach ($this->leaves as $leaf) {
$leaf->setName($leaf->getName(), $this->model->leafPath);
}
}
|
Called by the view's leaf class when it's leaf path is changed.
This cascades down all sub view and leaves.
|
entailment
|
final protected function getLayoutProvider()
{
$layout = LayoutProvider::getProvider();
$layout->generateValueEvent->attachHandler(function ($elementName) {
if (isset($this->leaves[$elementName])) {
return $this->leaves[$elementName];
}
return null;
});
return $layout;
}
|
Gets the default layout provider and binds to the generateValueEvent event
@return LayoutProvider
|
entailment
|
public function getState()
{
$state = get_object_vars($this);
$publicState = [];
foreach ($this->getExposableModelProperties() as $property) {
if (isset($state[$property])) {
$publicState[$property] = $state[$property];
}
}
return $publicState;
}
|
Returns an array of **publicly viewable** state data required to persist the state or provide state
information to a client side view bridge.
@return string[] An associative array of state key value pair strings.
|
entailment
|
public function restoreFromState($stateData)
{
$publicProperties = $this->getExposableModelProperties();
foreach ($publicProperties as $key) {
if (isset($stateData[$key])) {
$this->$key = $stateData[$key];
}
}
}
|
Restores the model from the passed state data.
@param string[] $stateData An associative array of state key value pair strings.
|
entailment
|
public static function fromArray(array $retweet): self
{
$extendedEntities = isset($retweet['extended_entities'])
? $retweet['extended_entities']
: null
;
$user = isset($retweet['user'])
? User::fromArray($retweet['user'])
: null
;
return new self(
$retweet['id'],
$retweet['text'],
$retweet['lang'],
$retweet['created_at'],
$retweet['geo'],
$retweet['coordinates'],
$retweet['place'],
$retweet['retweet_count'],
$retweet['favorite_count'],
$retweet['entities'],
$extendedEntities,
$user
);
}
|
Create Tweet from Array
@param array $retweet
@return RetweetedStatus
|
entailment
|
public function toArray(): array
{
return [
'id' => $this->id,
'text' => $this->text,
'lang' => $this->lang,
'created_at' => $this->createdAt,
'geo' => $this->geo,
'coordinates' => $this->coordinates,
'places' => $this->places,
'retweet_count' => $this->retweetCount,
'favorite_count' => $this->favoriteCount,
'entities' => $this->entities,
'extended_entities' => $this->extendedEntities,
'user' => $this->user
];
}
|
Return Tweet object to Array
@return array
|
entailment
|
final public function setName($name, $parentPath = "")
{
$this->model->leafName = $name;
if ($parentPath != "") {
$this->model->parentPath = $parentPath;
$this->model->isRootLeaf = false;
} else {
$this->model->parentPath = "";
}
$this->model->updatePath();
if ($this->view) {
$this->view->leafPathChanged();
}
}
|
Sets the name of the leaf.
@param $name string The new name for the leaf
@param $parentPath string The leaf path for the containing leaf
|
entailment
|
final public function setWebRequest(WebRequest $request)
{
if (self::$csrfValidation && $request->server('REQUEST_METHOD') == 'POST'){
CsrfProtection::singleton()->validateHeaders($request);
CsrfProtection::singleton()->validateCookie($request);
}
$this->request = $request;
$this->parseRequest($request);
$this->view->setWebRequest($request);
$this->model->onAfterRequestSet();
$this->onStateRestored();
}
|
Sets the web request being used to render the tree of leaves.
@param WebRequest $request
|
entailment
|
protected function parseRequest(WebRequest $request)
{
if ($this->model->isRootLeaf) {
$eventState = $request->post("_leafEventState");
if ($eventState !== null) {
$eventState = json_decode($eventState, true);
if ($eventState) {
$this->model->restoreFromState($eventState);
}
}
}
$targetWithoutIndexes = preg_replace('/\([^)]+\)/', "", $request->post("_leafEventTarget"));
if ($targetWithoutIndexes == $this->model->leafPath) {
$requestTargetParts = explode("_", $request->post("_leafEventTarget"));
$pathParts = explode("_", $this->model->leafPath);
if (preg_match('/\(([^)]+)\)/', $requestTargetParts[count($pathParts) - 1], $match)) {
$this->model->leafIndex = $match[1];
$this->model->updatePath();
}
$eventName = $request->post("_leafEventName");
$eventTarget = $request->post("_leafEventTarget");
$eventArguments = [];
if ($request->post("_leafEventArguments")) {
$args = $request->post("_leafEventArguments");
foreach ($args as $argument) {
$eventArguments[] = json_decode($argument, $this->objectsToAssocArrays);
}
}
if ($request->post("_leafEventArgumentsJson")) {
$jsonArguments = json_decode($request->post("_leafEventArgumentsJson"), true);
if (count($jsonArguments)) {
array_push($eventArguments, ...$jsonArguments);
}
}
// Provide a callback for the event processing.
$eventArguments[] = function ($response) use ($eventName, $eventTarget) {
if ($response === null) {
return;
}
$type = "";
if (is_object($response) || is_array($response)) {
$response = json_encode($response);
$type = ' type="json"';
}
print '<eventresponse event="' . $eventName . '" sender="' . $eventTarget . '"' . $type . '>
<![CDATA[' . $response . ']]>
</eventresponse>';
};
// First raise the event on the presenter itself
$this->runBeforeRender(function () use ($eventName, $eventArguments) {
$eventProperty = $eventName . "Event";
if (property_exists($this->model, $eventProperty)) {
/** @var Event $event */
$event = $this->model->$eventProperty;
return $event->raise(...$eventArguments);
}
return null;
});
}
}
|
Parses the request looking for client side events.
@param WebRequest $request
|
entailment
|
final public function generateResponse($request = null)
{
while (true) {
$this->setWebRequest($request);
try {
if ($request->header("Accept") == "application/leaf") {
$response = new XmlResponse($this);
$response->setContent($this->renderXhr());
} else {
$response = new HtmlResponse($this);
$response->setContent($this->render());
}
return $response;
} catch (RequiresViewReconfigurationException $er) {
$this->initialiseView();
}
}
return null;
}
|
Renders the Leaf and returns an HtmlResponse to Rhubarb
@param WebRequest|null $request
@return HtmlResponse|null
|
entailment
|
public function runBeforeRenderCallbacks()
{
$this->runningEventsBeforeRender = true;
foreach ($this->runBeforeRenderCallbacks as $callback) {
$callback();
}
$this->runBeforeRenderCallbacks = [];
// Ask the view to notify sub leaves
$this->view->runBeforeRenderCallbacks();
$this->runningEventsBeforeRender = false;
}
|
Run the before render callbacks.
|
entailment
|
public static function fromArray(array $tweet): self
{
$extendedEntities = isset($tweet['extended_entities'])
? $tweet['extended_entities']
: null
;
$user = User::fromArray($tweet['user']);
$retweetedStatus = isset($tweet['retweeted_status'])
? RetweetedStatus::fromArray($tweet['retweeted_status'])
: null
;
return new self(
$tweet['id'],
$tweet['text'],
$tweet['lang'],
$tweet['created_at'],
$tweet['timestamp_ms'],
$tweet['geo'],
$tweet['coordinates'],
$tweet['place'],
$tweet['retweet_count'],
$tweet['favorite_count'],
$tweet['entities'],
$extendedEntities,
$user,
$retweetedStatus
);
}
|
Create Tweet from Array
@param array $tweet
@return Tweet
|
entailment
|
public function serialized(): string
{
return serialize(
new self(
$this->id,
$this->text,
$this->lang,
$this->createdAt,
$this->timestampMs,
$this->geo,
$this->coordinates,
$this->places,
$this->retweetCount,
$this->favoriteCount,
$this->entities,
$this->extendedEntities,
$this->user,
$this->retweetedStatus
)
);
}
|
Return serialized Tweet object
@return string
|
entailment
|
public function map(Fluent $builder)
{
$builder->table('ext_log_entries');
$builder->entity()->setRepositoryClass(LogEntryRepository::class);
$builder->index(['object_class'])->name('log_class_lookup_idx');
$builder->index(['logged_at'])->name('log_date_lookup_idx');
$builder->index(['username'])->name('log_user_lookup_idx');
$builder->index(['object_id', 'object_class', 'version'])->name('log_version_lookup_idx');
}
|
{@inheritdoc}
|
entailment
|
public function build()
{
$builder = OverrideBuilderFactory::create(
$this->builder,
$this->namingStrategy,
$this->name,
$this->callback
);
$builder->build();
}
|
Execute the build process.
|
entailment
|
public function build()
{
$config = [
'loggable' => true,
];
if ($this->logEntry !== null) {
$config['logEntryClass'] = $this->logEntry;
}
$this->classMetadata->addExtension(Fluent::EXTENSION_NAME, array_merge(
$this->classMetadata->getExtension(Fluent::EXTENSION_NAME),
$config
));
}
|
Execute the build process.
|
entailment
|
public function build()
{
$this->classMetadata->addExtension($this->getExtensionName(), [
'softDeleteable' => true,
'fieldName' => $this->fieldName,
'timeAware' => $this->timeAware,
]);
}
|
Execute the build process.
|
entailment
|
public static function enable()
{
Builder::macro(self::MACRO_METHOD, function (Builder $builder) {
return new static($builder->getClassMetadata());
});
UploadableFile::enable();
}
|
Enable the Uploadable extension.
@return void
|
entailment
|
public function allow($type)
{
if (!is_array($type)) {
$type = func_get_args();
}
$this->allowedTypes = implode(',', $type);
return $this;
}
|
Allow only specific types.
@param array|string ...$type can be an array or multiple string parameters
@return Uploadable
|
entailment
|
public function disallow($type)
{
if (!is_array($type)) {
$type = func_get_args();
}
$this->disallowedTypes = implode(',', $type);
return $this;
}
|
Disallow specific types.
@param array|string ...$type can be an array or multiple string parameters
@return Uploadable
|
entailment
|
public function build()
{
$config = $this->getConfiguration();
Validator::validateConfiguration($this->classMetadata, $config);
$this->classMetadata->addExtension(UploadableDriver::EXTENSION_NAME, $config);
}
|
Execute the build process.
|
entailment
|
private function getConfiguration()
{
return array_merge(
[
'fileMimeTypeField' => false,
'fileNameField' => false,
'filePathField' => false,
'fileSizeField' => false,
],
$this->classMetadata->getExtension(UploadableDriver::EXTENSION_NAME),
[
'uploadable' => true,
'allowOverwrite' => $this->allowOverwrite,
'appendNumber' => $this->appendNumber,
'path' => $this->path,
'pathMethod' => $this->pathMethod,
'callback' => $this->callback,
'filenameGenerator' => $this->filenameGenerator,
'maxSize' => (float) $this->maxSize,
'allowedTypes' => $this->allowedTypes,
'disallowedTypes' => $this->disallowedTypes,
]
);
}
|
Build the configuration, based on defaults, current extension configuration and accumulated parameters.
@return array
|
entailment
|
protected function createAssociation(ClassMetadataBuilder $builder, $relation, $entity)
{
return $this->builder->createManyToOne(
$relation,
$entity
);
}
|
@param ClassMetadataBuilder $builder
@param string $relation
@param string $entity
@return AssociationBuilder
|
entailment
|
public function getJoinColumn(callable $callback = null)
{
$joinColumn = reset($this->joinColumns);
if (is_callable($callback)) {
$callback($joinColumn);
}
return $joinColumn;
}
|
@param callable|null $callback
@return JoinColumn|false
|
entailment
|
public function build()
{
$config = $this->classMetadata->getExtension(Fluent::EXTENSION_NAME);
$config['loggable'] = true;
$config['versioned'] = array_unique(array_merge(
isset($config['versioned']) ? $config['versioned'] : [],
[
$this->fieldName,
]
));
$this->classMetadata->addExtension(Fluent::EXTENSION_NAME, $config);
}
|
Execute the build process.
|
entailment
|
public static function enable()
{
Field::macro(self::MACRO_METHOD, function (Field $field) {
return new static($field->getClassMetadata(), $field->getName());
});
}
|
Enable TreePathSource.
|
entailment
|
public function build()
{
if (!(new Validator())->isValidFieldForPathSource($this->classMetadata, $this->fieldName)) {
throw new InvalidMappingException(
"Tree PathSource field - [{$this->fieldName}] type is not valid. It can be any of the integer variants, double, float or string in class - {$this->classMetadata->name}"
);
}
$this->classMetadata->mergeExtension($this->getExtensionName(), [
'path_source' => $this->fieldName,
]);
}
|
Execute the build process.
|
entailment
|
public function build()
{
if (strlen($this->separator) > 1) {
throw new InvalidMappingException("Tree Path field - [{$this->fieldName}] Separator {$this->separator} is invalid. It must be only one character long.");
}
$this->classMetadata->mergeExtension($this->getExtensionName(), [
'path' => $this->fieldName,
'path_separator' => $this->separator,
'path_append_id' => $this->appendId,
'path_starts_with_separator' => $this->startsWithSeparator,
'path_ends_with_separator' => $this->endsWithSeparator,
]);
}
|
Execute the build process.
|
entailment
|
public function column($column, $type = 'string', $length = 255)
{
$this->builder->setDiscriminatorColumn($column, $type, $length);
return $this;
}
|
Add the discriminator column.
@param string $column
@param string $type
@param int $length
@return Inheritance
|
entailment
|
public function map($name, $class = null)
{
if (is_array($name)) {
foreach ($name as $name => $class) {
$this->map($name, $class);
}
return $this;
}
$this->builder->addDiscriminatorMapClass($name, $class);
return $this;
}
|
@param string $name
@param string|null $class
@return Inheritance
|
entailment
|
public function table($name, callable $callback = null)
{
$this->disallowInEmbeddedClasses();
$table = new Table($this->builder, $name);
$this->callbackAndQueue($table, $callback);
return $table;
}
|
{@inheritdoc}
|
entailment
|
public function entity(callable $callback = null)
{
$this->disallowInEmbeddedClasses();
$entity = new Entity($this->builder, $this->namingStrategy);
$this->callIfCallable($callback, $entity);
return $entity;
}
|
{@inheritdoc}
|
entailment
|
public function inheritance($type, callable $callback = null)
{
$inheritance = Inheritance\InheritanceFactory::create($type, $this->builder);
$this->callIfCallable($callback, $inheritance);
return $inheritance;
}
|
{@inheritdoc}
|
entailment
|
public function embed($embeddable, $field = null, callable $callback = null)
{
$embedded = new Embedded(
$this->builder,
$this->namingStrategy,
$this->guessSingularField($embeddable, $field),
$embeddable
);
$this->callbackAndQueue($embedded, $callback);
return $embedded;
}
|
{@inheritdoc}
|
entailment
|
public function override($name, callable $callback)
{
$override = new Overrides\Override(
$this->getBuilder(),
$this->getNamingStrategy(),
$name,
$callback
);
$this->queue($override);
return $override;
}
|
{@inheritdoc}
|
entailment
|
public function events(callable $callback = null)
{
$events = new LifecycleEvents($this->builder);
$this->callbackAndQueue($events, $callback);
return $events;
}
|
{@inheritdoc}
|
entailment
|
public function listen(callable $callback = null)
{
$events = new EntityListeners($this->builder);
$this->callbackAndQueue($events, $callback);
return $events;
}
|
{@inheritdoc}
|
entailment
|
protected function setArray($name, callable $callback = null)
{
return $this->field(Type::TARRAY, $name, $callback);
}
|
@param string $name
@param callable|null $callback
@return Field
|
entailment
|
public function level($field = 'level', $type = 'integer', callable $callback = null)
{
$this->validateNumericField($type, $field);
$this->mapField($type, $field, $callback);
$this->level = $field;
return $this;
}
|
@param string $field
@param string $type
@param callable|null $callback
@throws InvalidMappingException
@return $this
|
entailment
|
public function parent($field = 'parent', callable $callback = null)
{
$this->addSelfReferencingRelation($field, $callback);
$this->parent = $field;
return $this;
}
|
@param string $field
@param callable|null $callback
@return $this
|
entailment
|
public function build()
{
$this->defaults();
$this->getClassMetadata()->mergeExtension($this->getExtensionName(), $this->getValues());
}
|
{@inheritdoc}
|
entailment
|
protected function alreadyConfigured($key)
{
$config = $this->getClassMetadata()->getExtension($this->getExtensionName());
return isset($config[$key]);
}
|
Check if a given key is already configured for this extension.
@param string $key
@return bool
|
entailment
|
public static function enable()
{
Builder::macro(self::MACRO_METHOD, function (Fluent $builder, $createdAt = 'createdAt', $updatedAt = 'updatedAt', $type = 'dateTime') {
$builder->{$type}($createdAt)->timestampable()->onCreate();
$builder->{$type}($updatedAt)->timestampable()->onUpdate();
});
}
|
Enable the extension.
@return void
|
entailment
|
public static function make(ClassMetadataBuilder $builder, $type, $name)
{
$type = Type::getType($type);
$field = $builder->createField($name, $type->getName());
return new static($field, $builder, $type, $name);
}
|
@param ClassMetadataBuilder $builder
@param string $type
@param string $name
@throws \Doctrine\DBAL\DBALException
@return Field
|
entailment
|
public function generatedValue(callable $callback = null)
{
$generatedValue = new GeneratedValue($this->fieldBuilder, $this->classMetadata);
if ($callback) {
$callback($generatedValue);
}
$generatedValue->build();
return $this;
}
|
@param callable|null $callback
@return Field
|
entailment
|
public function index($name = null)
{
$index = new Index(
$this->metaDatabuilder,
[$this->getName()]
);
if ($name !== null) {
$index->name($name);
}
$this->callbackAndQueue($index);
return $this;
}
|
@param string|null $name
@return Field
|
entailment
|
public function map(Fluent $builder)
{
$builder->integer('id')->unsigned()->primary()->generatedValue(function (GeneratedValue $builder) {
$builder->identity();
});
$builder->integer('depth');
}
|
{@inheritdoc}
|
entailment
|
protected function callMacro($method, array $params = [])
{
// Add builder as first closure param, append the given params
array_unshift($params, $this);
return call_user_func_array($this->getMacro($method), $params);
}
|
@param string $method
@param array $params
@return mixed
|
entailment
|
public function map(Fluent $builder)
{
$builder->integer('id')->unsigned()->primary()->generatedValue(function (GeneratedValue $builder) {
$builder->identity();
});
$builder->string('locale')->length(8);
$builder->string('objectClass')->name('object_class');
$builder->string('field')->length(32);
$builder->string('foreignKey')->length(64)->name('foreign_key');
$builder->text('content')->nullable();
}
|
{@inheritdoc}
|
entailment
|
public function build()
{
foreach ($this->getJoinColumns() as $column) {
$this->getAssociation()->addJoinColumn(
$column->getJoinColumn(),
$column->getReferenceColumn(),
$column->isNullable(),
$column->isUnique(),
$column->getOnDelete(),
$column->getColumnDefinition()
);
}
parent::build();
}
|
Build the association.
|
entailment
|
public function addJoinColumn(
$relation,
$joinColumn = null,
$referenceColumn = null,
$nullable = false,
$unique = false,
$onDelete = null,
$columnDefinition = null
) {
$joinColumn = new JoinColumn(
$this->getNamingStrategy(),
$relation,
$joinColumn,
$referenceColumn,
$nullable,
$unique,
$onDelete,
$columnDefinition
);
$this->pushJoinColumn($joinColumn);
return $this;
}
|
@param string $relation
@param string|null $joinColumn
@param string|null $referenceColumn
@param bool|false $nullable
@param bool|false $unique
@param string|null $onDelete
@param string|null $columnDefinition
@return $this
|
entailment
|
private function add($event, $class, $method = null)
{
$this->events[$event][] = [
'class' => $class,
'method' => $method ?: $event,
];
return $this;
}
|
@param string $event
@param string $class
@param string|null $method
@return EntityListeners
|
entailment
|
public function build()
{
foreach ($this->events as $event => $listeners) {
foreach ($listeners as $listener) {
$this->builder->getClassMetadata()->addEntityListener($event, $listener['class'], $listener['method']);
}
}
}
|
Execute the build process.
|
entailment
|
public function build()
{
$this->isValidField($this->classMetadata, $this->fieldName);
$this->classMetadata->appendExtension($this->getExtensionName(), [
'slugs' => [
$this->fieldName => $this->makeConfiguration(),
],
]);
}
|
Execute the build process.
|
entailment
|
protected function isValidField(ClassMetadataInfo $meta, $field)
{
$mapping = $meta->getFieldMapping($field);
if (!$mapping || !in_array($mapping['type'], $this->validTypes)) {
throw new InvalidArgumentException('Sluggable field is not a valid field type');
}
return true;
}
|
Checks if $field type is valid as Sluggable field.
@param ClassMetadataInfo $meta
@param string $field
@throws InvalidArgumentException
@return bool
|
entailment
|
public function map(Fluent $builder)
{
$builder->table('ext_translations');
$builder->entity()->setRepositoryClass(TranslationRepository::class);
$builder->index(['locale', 'object_class', 'foreign_key'])->name('translations_lookup_idx');
$builder->unique(['locale', 'object_class', 'field', 'foreign_key'])->name('lookup_unique_idx');
}
|
{@inheritdoc}
|
entailment
|
public function build()
{
if ($this->classMetadata->hasField($this->fieldName)) {
throw new InvalidMappingException(
"Locale field [{$this->fieldName}] should not be mapped as column property in entity - {$this->classMetadata->name}, since it makes no sense"
);
}
$this->classMetadata->appendExtension($this->getExtensionName(), [
'locale' => $this->fieldName,
]);
}
|
Execute the build process.
|
entailment
|
protected function createAssociation(ClassMetadataBuilder $builder, $relation, $entity)
{
return $this->builder->createOneToOne(
$relation,
$entity
);
}
|
@param ClassMetadataBuilder $builder
@param string $relation
@param string $entity
@return AssociationBuilder
|
entailment
|
public static function registerAll(MappingDriverChain $driverChain)
{
self::register($driverChain, array_merge(self::$abstract, self::$concrete));
}
|
Register all Gedmo classes on Fluent.
@param MappingDriverChain $driverChain
@return void
@see \Gedmo\DoctrineExtensions::registerMappingIntoDriverChainORM
|
entailment
|
protected static function register(MappingDriverChain $driverChain, array $mappings)
{
$driverChain->addDriver(
new FluentDriver($mappings),
'Gedmo'
);
foreach (self::$extensions as $extension) {
$extension::enable();
}
}
|
Register a new FluentDriver for the Gedmo namespace on the given chain.
Adds all extensions as macros.
@param MappingDriverChain $driverChain
@param string[] $mappings
@return void
|
entailment
|
public function build()
{
$callback = $this->callback;
// We will create a new class metadata builder instance,
// so we can use it to easily generated a new mapping
// array, without re-declaring the existing field
$builder = $this->newClassMetadataBuilder();
$source = $this->convertToMappingArray($this->builder);
// Create a new field builder for the new class metadata builder,
// based on the existing (to be overridden) field
$fieldBuilder = $this->getFieldBuilder(
$builder,
$source
);
$field = $callback($fieldBuilder);
// When the user forget to return, use the Field instance
// which contains the same information
$field = $field ?: $fieldBuilder;
if (!$field instanceof Field) {
throw new InvalidArgumentException('The callback should return an instance of '.Field::class);
}
$field->build();
$target = $this->convertToMappingArray($builder);
$this->builder->getClassMetadata()->setAttributeOverride(
$this->name,
$this->mergeRecursively($source, $target)
);
}
|
Execute the build process.
|
entailment
|
protected function getFieldBuilder(ClassMetadataBuilder $builder, array $mapping)
{
return Field::make(
$builder,
$mapping['type'],
$this->name
);
}
|
@param ClassMetadataBuilder $builder
@param array $mapping
@return Field
|
entailment
|
protected function convertToMappingArray(ClassMetadataBuilder $builder)
{
$metadata = $builder->getClassMetadata();
return $metadata->getFieldMapping($this->name);
}
|
@param ClassMetadataBuilder $builder
@throws \Doctrine\ORM\Mapping\MappingException
@return array
|
entailment
|
protected function constraint($class, array $columns)
{
$constraint = new $class($this->getBuilder(), $columns);
$this->queue($constraint);
return $constraint;
}
|
@param string $class
@param array $columns
@return mixed
|
entailment
|
public function hasOne($entity, $field = null, callable $callback = null)
{
return $this->oneToOne($entity, $field, $callback)->ownedBy(
$this->guessSingularField($entity)
);
}
|
{@inheritdoc}
|
entailment
|
public function oneToOne($entity, $field = null, callable $callback = null)
{
return $this->addRelation(
new OneToOne(
$this->getBuilder(),
$this->getNamingStrategy(),
$this->guessSingularField($entity, $field),
$entity
),
$callback
);
}
|
{@inheritdoc}
|
entailment
|
public function belongsTo($entity, $field = null, callable $callback = null)
{
return $this->manyToOne($entity, $field, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function manyToOne($entity, $field = null, callable $callback = null)
{
return $this->addRelation(
new ManyToOne(
$this->getBuilder(),
$this->getNamingStrategy(),
$this->guessSingularField($entity, $field),
$entity
),
$callback
);
}
|
{@inheritdoc}
|
entailment
|
public function hasMany($entity, $field = null, callable $callback = null)
{
return $this->oneToMany($entity, $field, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function oneToMany($entity, $field = null, callable $callback = null)
{
return $this->addRelation(
new OneToMany(
$this->getBuilder(),
$this->getNamingStrategy(),
$this->guessPluralField($entity, $field),
$entity
),
$callback
);
}
|
{@inheritdoc}
|
entailment
|
public function belongsToMany($entity, $field = null, callable $callback = null)
{
return $this->manyToMany($entity, $field, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function manyToMany($entity, $field = null, callable $callback = null)
{
return $this->addRelation(
new ManyToMany(
$this->getBuilder(),
$this->getNamingStrategy(),
$this->guessPluralField($entity, $field),
$entity
),
$callback
);
}
|
{@inheritdoc}
|
entailment
|
public function addRelation(Relation $relation, callable $callback = null)
{
$this->callbackAndQueue($relation, $callback);
return $relation;
}
|
{@inheritdoc}
|
entailment
|
protected function guessSingularField($entity, $field = null)
{
return $field ?: Inflector::singularize(
lcfirst(basename(str_replace('\\', '/', $entity)))
);
}
|
@param string $entity
@param string|null $field
@return string
|
entailment
|
protected function guessPluralField($entity, $field = null)
{
return $field ?: Inflector::pluralize($this->guessSingularField($entity));
}
|
@param string $entity
@param string|null $field
@return string
|
entailment
|
public function getMapperFor($className)
{
if (!$this->hasMapperFor($className)) {
throw new MappingException(sprintf(
'Class [%s] does not have a mapping configuration. '.
'Make sure you create a Mapping class that extends either %s, %s or %s. '.
'If you are using inheritance mapping, remember to create mappings '.
'for every child of the inheritance tree.',
$className,
EntityMapping::class,
EmbeddableMapping::class,
MappedSuperClassMapping::class
));
}
return $this->mappers[$className];
}
|
@param string $className
@throws MappingException
@return Mapper
|
entailment
|
protected function queueMacro($method, $args)
{
$result = $this->callMacro($method, $args);
if ($result instanceof Buildable) {
$this->queue($result);
}
return $result;
}
|
Intercept the Macro call and queue the result if it's a Buildable object.
@param string $method
@param array $args
@return mixed
|
entailment
|
public function field($type, $name, callable $callback = null)
{
$field = Field::make($this->getBuilder(), $type, $name);
$this->callbackAndQueue($field, $callback);
return $field;
}
|
{@inheritdoc}
|
entailment
|
public function string($name, callable $callback = null)
{
return $this->field(Type::STRING, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function text($name, callable $callback = null)
{
return $this->field(Type::TEXT, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function integer($name, callable $callback = null)
{
return $this->field(Type::INTEGER, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function smallInteger($name, callable $callback = null)
{
return $this->field(Type::SMALLINT, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function bigInteger($name, callable $callback = null)
{
return $this->field(Type::BIGINT, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function guid($name, callable $callback = null)
{
return $this->field(Type::GUID, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function blob($name, callable $callback = null)
{
return $this->field(Type::BLOB, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function object($name, callable $callback = null)
{
return $this->field(Type::OBJECT, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function float($name, callable $callback = null)
{
return $this->field(Type::FLOAT, $name, $callback)->precision(8)->scale(2);
}
|
{@inheritdoc}
|
entailment
|
public function decimal($name, callable $callback = null)
{
return $this->field(Type::DECIMAL, $name, $callback)->precision(8)->scale(2);
}
|
{@inheritdoc}
|
entailment
|
public function boolean($name, callable $callback = null)
{
return $this->field(Type::BOOLEAN, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function simpleArray($name, callable $callback = null)
{
return $this->field(Type::SIMPLE_ARRAY, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function jsonArray($name, callable $callback = null)
{
return $this->field(Type::JSON_ARRAY, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function binary($name, callable $callback = null)
{
return $this->field(Type::BINARY, $name, $callback)->nullable();
}
|
{@inheritdoc}
|
entailment
|
public function map(Fluent $builder)
{
$builder->increments('id');
$builder->string('action')->length(8);
$builder->dateTime('loggedAt')->name('logged_at');
$builder->string('objectId')->name('object_id')->length(64)->nullable();
$builder->string('objectClass')->name('object_class');
$builder->integer('version');
$builder->array('data')->nullable();
$builder->string('username')->nullable();
}
|
{@inheritdoc}
|
entailment
|
public static function create($type, ClassMetadataBuilder $builder)
{
if (isset(static::$map[$type])) {
return new static::$map[$type]($builder);
}
throw new InvalidArgumentException("Inheritance type [{$type}] does not exist. SINGLE_TABLE and JOINED are support");
}
|
@param string $type
@param ClassMetadataBuilder $builder
@return Inheritance
|
entailment
|
public static function enable()
{
foreach (self::$validTypes as $type) {
Field::macro("asFile$type", function (Field $builder) use ($type) {
return new static($builder->getClassMetadata(), $builder->getName(), $type);
});
}
}
|
Enable the UploadableFile extension.
@return void
|
entailment
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.