sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
public function build()
{
$this->classMetadata->appendExtension(UploadableDriver::EXTENSION_NAME, [
$this->type => $this->fieldName,
]);
}
|
Execute the build process.
|
entailment
|
private function validateType($type)
{
if (!in_array($type, self::$validTypes)) {
throw new InvalidMappingException(
'Invalid uploadable field type reference. Must be one of: '.implode(', ', self::$validTypes)
);
}
}
|
Validate the given type of file field.
@param string $type
@return void
|
entailment
|
public function setUsage($usage)
{
if (is_int($usage)) {
$this->validate($usage, $this->usages);
} else {
$this->validate($usage, array_keys($this->usages));
$usage = $this->usages[$usage];
}
$this->usage = $usage;
return $this;
}
|
@param string $usage
@throws InvalidArgumentException
@return AssociationCache
|
entailment
|
public function build()
{
$this->metadata->enableAssociationCache($this->field, [
'usage' => $this->getUsage(),
'region' => $this->getRegion(),
]);
}
|
Execute the build process.
|
entailment
|
protected function validate($usage, array $usages)
{
if (!in_array($usage, $usages)) {
throw new InvalidArgumentException(
'['.$usage.'] is not a valid cache usage. Available: '.implode(', ', array_keys($this->usages))
);
}
return $usage;
}
|
@param string|int $usage
@param array $usages
@return mixed
|
entailment
|
public function build()
{
if ($this->on === null) {
throw new InvalidMappingException(
"Field - [{$this->fieldName}] trigger 'on' is not one of [update, create, change] in class - {$this->classMetadata->name}");
}
if (is_array($this->trackedFields) && $this->value !== null) {
throw new InvalidMappingException('Extension does not support multiple value change-set detection yet.');
}
$this->classMetadata->appendExtension($this->getExtensionName(), [
$this->on => [
$this->makeConfiguration(),
],
]);
}
|
Execute the build process.
|
entailment
|
protected function on($on, $fields = null, $value = null)
{
$this->on = $on;
$this->trackedFields = $fields;
$this->value = $value;
return $this;
}
|
@param string $on
@param array|string|null $fields
@param string|null $value
@return $this
|
entailment
|
protected function makeConfiguration()
{
if ($this->on == 'create' || $this->on == 'update') {
return $this->fieldName;
}
return [
'field' => $this->fieldName,
'trackedField' => $this->trackedFields,
'value' => $this->value,
];
}
|
Returns either the field name on "create" and "update", or the array configuration on "change".
@return array|string
|
entailment
|
public function cascade(array $cascade)
{
foreach ($cascade as $name) {
$method = 'cascade'.Inflector::classify(strtolower($name));
if (!method_exists($this->association, $method)) {
throw new InvalidArgumentException('Cascade ['.$name.'] does not exist');
}
$this->{$method}();
}
return $this;
}
|
@param string[] $cascade one of "persist", "remove", "merge", "detach", "refresh" or "ALL"
@return $this
|
entailment
|
public function fetch($strategy)
{
$method = 'fetch'.Inflector::classify(strtolower($strategy));
if (!method_exists($this->association, $method)) {
throw new InvalidArgumentException('Fetch ['.$strategy.'] does not exist');
}
$this->{$method}();
return $this;
}
|
@param string $strategy one of "LAZY", "EAGER", "EXTRA_LAZY"
@return $this
|
entailment
|
public function cache($usage = 'READ_ONLY', $region = null)
{
$cache = new AssociationCache(
$this->builder->getClassMetadata(),
$this->relation,
$usage,
$region
);
$this->queue($cache);
return $this;
}
|
@param string $usage
@param string|null $region
@return $this
|
entailment
|
public static function enable()
{
Field::macro(self::MACRO_METHOD, function (Field $builder) {
return new static($builder->getClassMetadata(), $builder->getName());
});
ManyToOne::macro(self::MACRO_METHOD, function (ManyToOne $builder) {
return new static($builder->getClassMetadata(), $builder->getRelation());
});
}
|
Enable the extension.
@return void
|
entailment
|
public function build()
{
$this->builder->addEmbedded(
$this->relation,
$this->embeddable,
$this->columnPrefix
);
}
|
Execute the build process.
|
entailment
|
public function appendExtension($name, array $config = [])
{
$merged = array_merge_recursive(
$this->getExtension($name),
$config
);
$this->addExtension($name, $merged);
}
|
Merge with current extension configuration, appending new values to old ones.
@param string $name
@param array $config
|
entailment
|
public function mergeExtension($name, array $config)
{
$this->addExtension($name, array_merge(
$this->getExtension($name),
$config
));
}
|
Merge with current extension configuration, overwriting with new values.
@param string $name
@param array $config
@return void
|
entailment
|
public function auto($name = null, $initial = null, $size = null)
{
$this->strategy = 'AUTO';
$this->customize($name, $initial, $size);
return $this;
}
|
Tells Doctrine to pick the strategy that is preferred by the used database platform. The preferred strategies
are IDENTITY for MySQL, SQLite, MsSQL and SQL Anywhere and SEQUENCE for Oracle and PostgreSQL. This strategy
provides full portability.
@param string|null $name
@param string|null $initial
@param string|null $size
@return $this
|
entailment
|
public function sequence($name = null, $initial = null, $size = null)
{
$this->strategy = 'SEQUENCE';
$this->customize($name, $initial, $size);
return $this;
}
|
Tells Doctrine to use a database sequence for ID generation. This strategy does currently not provide full
portability. Sequences are supported by Oracle, PostgreSql and SQL Anywhere.
@param string|null $name
@param string|null $initial
@param string|null $size
@return $this
|
entailment
|
public function build()
{
$this->builder->generatedValue($this->strategy);
if ($this->name) {
$this->builder->setSequenceGenerator($this->name, $this->size, $this->initial);
}
if ($this->generator) {
$this->classMetadata->setCustomGeneratorDefinition(['class' => $this->generator]);
}
}
|
Execute the build process.
|
entailment
|
public function build()
{
foreach ($this->events as $event => $methods) {
foreach ($methods as $method) {
$this->builder->addLifecycleEvent($method, $event);
}
}
}
|
Execute the build process.
|
entailment
|
protected function createAssociation(ClassMetadataBuilder $builder, $relation, $entity)
{
return $this->builder->createOneToMany($relation, $entity);
}
|
@param ClassMetadataBuilder $builder
@param string $relation
@param string $entity
@return OneToManyAssociationBuilder
|
entailment
|
public function path($field = 'path', $separator = '|', callable $callback = null)
{
$this->mapField('string', $field, null, true);
$this->path = new TreePath($this->getClassMetadata(), $field, $separator);
$this->callbackAndQueue($this->path, $callback);
return $this;
}
|
@param string $field
@param string $separator
@param callable|null $callback
@return $this
|
entailment
|
protected function defaults()
{
parent::defaults();
if ($this->isMissingPath()) {
$this->path();
}
if ($this->isMissingSource()) {
$this->pathSource();
}
}
|
Add default values to all required fields.
@return void
|
entailment
|
public function date($name, callable $callback = null)
{
return $this->field(Type::DATE, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function dateTime($name, callable $callback = null)
{
return $this->field(Type::DATETIME, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function dateTimeTz($name, callable $callback = null)
{
return $this->field(Type::DATETIMETZ, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function time($name, callable $callback = null)
{
return $this->field(Type::TIME, $name, $callback);
}
|
{@inheritdoc}
|
entailment
|
public function build()
{
/** @var Buildable[] $delayed */
$delayed = [];
foreach ($this->getQueued() as $buildable) {
if ($buildable instanceof Delay) {
$delayed[] = $buildable;
} else {
$buildable->build();
}
}
foreach ($delayed as $buildable) {
$buildable->build();
}
}
|
Execute the build process for all queued buildables.
|
entailment
|
public static function create(ClassMetadataBuilder $builder, NamingStrategy $namingStrategy, $name, callable $callback)
{
foreach (self::getFactories() as $buildable => $check) {
if ($check($builder->getClassMetadata(), $name)) {
return new $buildable($builder, $namingStrategy, $name, $callback);
}
}
throw new InvalidArgumentException('No attribute or association could be found for '.$name);
}
|
@param ClassMetadataBuilder $builder
@param NamingStrategy $namingStrategy
@param $name
@param callable $callback
@return
|
entailment
|
protected static function addMacro($method, $key)
{
Field::macro($method, function (Field $field) use ($key) {
$field->nullable();
return new static($field->getClassMetadata(), $field->getName(), $key);
});
ManyToOne::macro($method, function (ManyToOne $relation) use ($key) {
$relation->nullable();
return new static($relation->getClassMetadata(), $relation->getRelation(), $key);
});
}
|
@param string $method
@param string $key
@return void
|
entailment
|
public function build()
{
$this->classMetadata->mergeExtension($this->getExtensionName(), [
$this->key => $this->fieldName,
]);
}
|
Execute the build process.
|
entailment
|
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
$this->mappers->getMapperFor($className)->map(
$this->getFluent($metadata)
);
}
|
Loads the metadata for the specified class into the provided container.
@param string $className
@param ClassMetadata $metadata
|
entailment
|
public function isTransient($className)
{
return
!$this->mappers->hasMapperFor($className) ||
$this->mappers->getMapperFor($className)->isTransient();
}
|
Returns whether the class with the specified name should have its metadata loaded.
This is only the case if it is either mapped as an Entity or a MappedSuperclass.
@param string $className
@return bool
|
entailment
|
public function cacheable($usage = ClassMetadataInfo::CACHE_USAGE_READ_ONLY, $region = null)
{
$meta = $this->builder->getClassMetadata();
$meta->enableCache(compact('usage', $region === null ?: 'region'));
return $this;
}
|
Enables second-level cache on this entity.
If you want to enable second-level cache,
you must enable it on the EntityManager configuration.
Depending on the cache mode selected, you may also need to configure
lock modes.
@param int $usage Cache mode. use ClassMetadataInfo::CACHE_USAGE_* constants.
Defaults to READ_ONLY mode.
@param string|null $region The cache region to be used. Doctrine will use a default region
for each entity, if none is provided.
@return Entity
@see http://doctrine-orm.readthedocs.org/en/latest/reference/second-level-cache.html
|
entailment
|
public function increments($name, callable $callback = null)
{
$this->disallowInEmbeddedClasses();
return $this->integer($name, $callback)->primary()->unsigned()->autoIncrement();
}
|
{@inheritdoc}
|
entailment
|
public function smallIncrements($name, callable $callback = null)
{
$this->disallowInEmbeddedClasses();
return $this->smallInteger($name, $callback)->primary()->unsigned()->autoIncrement();
}
|
{@inheritdoc}
|
entailment
|
public function bigIncrements($name, callable $callback = null)
{
$this->disallowInEmbeddedClasses();
return $this->bigInteger($name, $callback)->primary()->unsigned()->autoIncrement();
}
|
{@inheritdoc}
|
entailment
|
public function rememberToken($name = 'rememberToken', callable $callback = null)
{
return $this->string($name, $callback)->nullable()->length(100);
}
|
{@inheritdoc}
|
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 association
$builder = $this->newClassMetadataBuilder();
$source = $this->convertToMappingArray($this->builder);
if (!isset($this->relations[$source['type']])) {
throw new InvalidArgumentException('Only ManyToMany and ManyToOne relations can be overridden');
}
// Create a new association builder, based on the given type
$associationBuilder = $this->getAssociationBuilder($builder, $source);
// Give the original join table name, so we won't
// accidentally remove custom join table names
if ($this->hasJoinTable($source)) {
$associationBuilder->setJoinTable($source['joinTable']['name']);
}
$association = $callback($associationBuilder);
// When the user forget to return, use the $associationBuilder instance
// which contains the same information
$association = $association ?: $associationBuilder;
if (!$association instanceof Relation) {
throw new InvalidArgumentException('The callback should return an instance of '.Relation::class);
}
$association->build();
$target = $this->convertToMappingArray($builder);
$overrideMapping = [];
// ManyToMany mappings
if ($this->hasJoinTable($target)) {
$overrideMapping['joinTable'] = $this->mapJoinTable(
$target['joinTable'],
$source['joinTable']
);
}
// ManyToOne mappings
if ($this->hasJoinColumns($target)) {
$overrideMapping['joinColumns'] = $this->mapJoinColumns(
$target['joinColumns'],
$source['joinColumns']
);
}
$this->builder->getClassMetadata()->setAssociationOverride(
$this->name,
$overrideMapping
);
}
|
Execute the build process.
|
entailment
|
protected function convertToMappingArray(ClassMetadataBuilder $builder)
{
$metadata = $builder->getClassMetadata();
return $metadata->getAssociationMapping($this->name);
}
|
@param ClassMetadataBuilder $builder
@throws \Doctrine\ORM\Mapping\MappingException
@return array
|
entailment
|
protected function getAssociationBuilder(ClassMetadataBuilder $builder, array $source)
{
return new $this->relations[$source['type']](
$builder,
$this->namingStrategy,
$this->name,
$source['targetEntity']
);
}
|
@param $builder
@param $source
@return mixed
|
entailment
|
protected function mapJoinTable(array $target = [], array $source = [])
{
$joinTable['name'] = $target['name'];
if ($this->hasJoinColumns($target)) {
$joinTable['joinColumns'] = $this->mapJoinColumns(
$target['joinColumns'],
$source['joinColumns']
);
}
if ($this->hasInverseJoinColumns($target)) {
$joinTable['inverseJoinColumns'] = $this->mapJoinColumns(
$target['inverseJoinColumns'],
$source['inverseJoinColumns']
);
}
return $joinTable;
}
|
@param array $target
@param array $source
@return array
|
entailment
|
protected function mapJoinColumns(array $target = [], array $source = [])
{
$joinColumns = [];
foreach ($target as $index => $joinColumn) {
if (isset($source[$index])) {
$diff = array_diff($joinColumn, $source[$index]);
if (!empty($diff)) {
$joinColumns[] = $diff;
}
}
}
return $joinColumns;
}
|
@param array $target
@param array $source
@return mixed
@internal param $target
@internal param $source
@internal param $overrideMapping
|
entailment
|
public static function enable()
{
Builder::macro(self::MACRO_METHOD, function (Fluent $builder, callable $callback = null) {
$tree = new static($builder);
if (is_callable($callback)) {
call_user_func($callback, $tree);
}
return $tree;
});
NestedSet::enable();
MaterializedPath::enable();
ClosureTable::enable();
}
|
Enable extension.
|
entailment
|
public static function enable()
{
Field::macro(self::MACRO_METHOD, function (Field $builder) {
return new static($builder->getClassMetadata(), $builder->getName());
});
Timestamps::enable();
}
|
Enable the extension.
@return void
|
entailment
|
protected function createAssociation(ClassMetadataBuilder $builder, $relation, $entity)
{
return $this->builder->createManyToMany($relation, $entity);
}
|
@param ClassMetadataBuilder $builder
@param string $relation
@param string $entity
@return OneToManyAssociationBuilder
|
entailment
|
public function joinColumn($joinColumn, $references = 'id', $unique = false)
{
$this->addJoinColumn(null, $joinColumn, $references, false, $unique);
return $this;
}
|
@param string $joinColumn
@param string $references
@param bool $unique
@return $this
|
entailment
|
public function foreignKey($foreignKey, $references = 'id', $unique = false)
{
return $this->joinColumn($foreignKey, $references, $unique);
}
|
@param string $foreignKey
@param string $references
@param bool $unique
@return $this
|
entailment
|
public function inverseKey($inverseKey, $references = 'id', $unique = false)
{
$this->association->addInverseJoinColumn($inverseKey, $references, false, $unique);
return $this;
}
|
@param string $inverseKey
@param string $references
@param bool $unique
@return $this
|
entailment
|
public function target($inverseKey, $references = 'id', $unique = false)
{
return $this->inverseKey($inverseKey, $references, $unique);
}
|
@param string $inverseKey
@param string $references
@param bool $unique
@return $this
|
entailment
|
public function left($field = 'left', $type = 'integer', callable $callback = null)
{
$this->validateNumericField($type, $field);
$this->mapField($type, $field, $callback);
$this->left = $field;
return $this;
}
|
@param string $field
@param string $type
@param callable|null $callback
@throws InvalidMappingException
@return $this
|
entailment
|
public function right($field = 'right', $type = 'integer', callable $callback = null)
{
$this->validateNumericField($type, $field);
$this->mapField($type, $field, $callback);
$this->right = $field;
return $this;
}
|
@param string $field
@param string $type
@param callable|null $callback
@throws InvalidMappingException
@return $this
|
entailment
|
public function root($field = 'root', callable $callback = null)
{
$this->addSelfReferencingRelation($field, $callback);
$this->root = $field;
return $this;
}
|
@param string $field
@param callable|null $callback
@return $this
|
entailment
|
protected function defaults()
{
parent::defaults();
if ($this->isMissingLeft()) {
$this->left();
}
if ($this->isMissingRight()) {
$this->right();
}
}
|
Add default values to all required fields.
@return void
|
entailment
|
public function readExtendedMetadata($meta, array &$config)
{
if (!$meta instanceof ExtensibleClassMetadata) {
return;
}
$config = array_merge_recursive($config, $meta->getExtension(
$this->getExtensionName()
));
}
|
Read extended metadata configuration for
a single mapped class.
@param ExtensibleClassMetadata $meta
@param array $config
@return void
|
entailment
|
private function extractFluentDriver(MappingDriver $driver)
{
if ($driver instanceof FluentDriver) {
return $driver;
}
if ($driver instanceof MappingDriverChain) {
$default = $driver->getDefaultDriver();
if ($default instanceof FluentDriver) {
return $default;
}
foreach ($driver->getDrivers() as $namespace => $driver) {
if ($driver instanceof FluentDriver) {
return $driver;
}
}
}
throw new \UnexpectedValueException('Fluent driver not found in the driver chain.');
}
|
@param MappingDriver $driver
@return FluentDriver
|
entailment
|
public function create($options = NULL) {
return $this->request("POST", self::URL_TOKENS, $api_key = $this->culqi->api_key, $options, true);
}
|
@param array|null $options
@return create Token response.
|
entailment
|
public function all($options) {
return $this->request("GET", self::URL_ORDERS, $api_key = $this->culqi->api_key, $options);
}
|
@param array|null $options
@return Get all Orders
|
entailment
|
public function confirm($id = NULL) {
return $this->request("POST", self::URL_ORDERS . $id . "/confirm/", $api_key = $this->culqi->api_key);
}
|
@param array|null $options
@return confirm Order
|
entailment
|
public function get($id) {
return $this->request("GET", self::URL_ORDERS . $id . "/", $api_key = $this->culqi->api_key);
}
|
@param string|null $id
@return get a Order
|
entailment
|
public function delete($id) {
return $this->request("DELETE", self::URL_ORDERS . $id . "/", $api_key = $this->culqi->api_key);
}
|
@param string|null $id
@return delete a Order
|
entailment
|
public function all($options) {
return $this->request("GET", self::URL_PLANS, $api_key = $this->culqi->api_key, $options);
}
|
@param array|null $options
@return all Plans.
|
entailment
|
public function get($id) {
return $this->request("GET", self::URL_PLANS . $id . "/", $api_key = $this->culqi->api_key);
}
|
@param string|null $id
@return get a Plan.
|
entailment
|
public function delete($id) {
return $this->request("DELETE", self::URL_PLANS . $id . "/", $api_key = $this->culqi->api_key);
}
|
@param string|null $id
@return delete a Plan.
|
entailment
|
public function update($id = NULL, $options = NULL) {
return $this->request("PATCH", self::URL_PLANS . $id . "/", $api_key = $this->culqi->api_key, $options);
}
|
@param string|null $id
@param array|null $options
@return update Plan response.
|
entailment
|
public function all($options = NULL) {
return $this->request("GET", self::URL_SUBSCRIPTIONS, $api_key = $this->culqi->api_key, $options);
}
|
@param array|null $options
@return all Subscriptions.
|
entailment
|
public function delete($id = NULL) {
return $this->request("DELETE", self::URL_SUBSCRIPTIONS . $id . "/", $api_key = $this->culqi->api_key);
}
|
@param string|null $id
@return delete a Subscription response.
|
entailment
|
public function call(string $method, array $params = []) : StreamInterface
{
$url = $this->getApiUrl($method, $params);
try {
return $this->httpClient->request('GET', $url)->getBody();
} catch (ClientException $e) {
if ($e->getResponse() === null) {
throw new InternalServerErrorException(
'Server Error',
StatusCodes::INTERNAL_SERVER_ERROR
);
}
$status = $e->getResponse()->getStatusCode();
if ($status >= StatusCodes::INTERNAL_SERVER_ERROR) {
throw new InternalServerErrorException('Server Error', $status);
}
$response = json_decode($e->getResponse()->getBody()->getContents(), true);
if (!array_key_exists('error', $response)) {
throw new InternalServerErrorException('Server Error', $status);
}
throw new ErrorException($response['error']['message'], $response['error']['code']);
} catch (\Exception $e) {
throw new ApixuException($e->getMessage(), $e->getCode(), $e);
}
}
|
{@inheritdoc}
|
entailment
|
public function conditions() : Conditions
{
$url = sprintf(Config::DOC_WEATHER_CONDITIONS_URL, Config::FORMAT);
$response = $this->api->call($url);
return $this->getResponse($response, Conditions::class);
}
|
{@inheritdoc}
|
entailment
|
public function current(string $query) : CurrentWeather
{
$this->validateQuery($query);
$response = $this->api->call('current', ['q' => $query]);
return $this->getResponse($response, CurrentWeather::class);
}
|
{@inheritdoc}
|
entailment
|
public function search(string $query) : Search
{
$this->validateQuery($query);
$response = $this->api->call('search', ['q' => $query]);
return $this->getResponse($response, Search::class);
}
|
{@inheritdoc}
|
entailment
|
public function forecast(string $query, int $days, int $hour = null) : Forecast
{
$this->validateQuery($query);
$params = [
'q' => $query,
'days' => $days,
];
if ($hour !== null) {
$params['hour'] = $hour;
}
$response = $this->api->call('forecast', $params);
return $this->getResponse($response, Forecast::class);
}
|
{@inheritdoc}
|
entailment
|
public function history(string $query, \DateTime $since, \DateTime $until = null) : History
{
$this->validateQuery($query);
$params = [
'q' => $query,
'dt' => $since->format(self::$historyDateFormat),
];
if ($until !== null) {
$params['end_dt'] = $until->format(self::$historyDateFormat);
}
$response = $this->api->call('history', $params);
return $this->getResponse($response, History::class);
}
|
{@inheritdoc}
|
entailment
|
public function get($item)
{
$data = $this->getData();
return empty($data->$item) ? null : $data->$item;
}
|
Get from Data Attribute.
@param $item
@return null|mixed
|
entailment
|
public function boot()
{
$this->publishFiles();
$this->loadItems();
/**
* Register singleton.
*/
$this->app->singleton('tzsk-payu', function ($app) {
return new PayuGateway();
});
}
|
Perform post-registration booting of services.
@return void
|
entailment
|
public function capture()
{
$storage = new Storage();
$config = new Config($storage->getAccount());
if ($config->getDriver() == 'database') {
return PayuPayment::find($storage->getPayment());
}
return new PayuPayment($storage->getPayment());
}
|
Receive Payment and Return Payment Model.
@return PayuPayment
|
entailment
|
public function verify($transactionId)
{
session()->put('tzsk_payu_data', ['account' => $this->account]);
$transactionId = is_array($transactionId) ?
$transactionId : explode('|', $transactionId);
return $this->getVerifier($transactionId)->verify();
}
|
Get Status of a given Transaction.
@param $transactionId string
@return object
|
entailment
|
public function getStatus()
{
switch (strtolower($this->request->status)) {
case 'success':
return self::STATUS_COMPLETED;
case 'pending':
return self::STATUS_PENDING;
case 'failure':
return self::STATUS_FAILED;
default:
return self::STATUS_FAILED;
}
}
|
Get the status of the Payment.
@return string
|
entailment
|
public function up()
{
Schema::create('payu_payments', function (Blueprint $table) {
$table->increments('id');
$table->string('account');
$table->unsignedInteger('payable_id')->nullable();
$table->string('payable_type')->nullable();
$table->string('txnid');
$table->string('mihpayid');
$table->string('firstname');
$table->string('lastname')->nullable();
$table->string('email');
$table->string('phone');
$table->double('amount');
$table->double('discount')->default(0);
$table->double('net_amount_debit')->default(0);
$table->text('data');
$table->string('status');
$table->string('unmappedstatus');
$table->string('mode')->nullable();
$table->string('bank_ref_num')->nullable();
$table->string('bankcode')->nullable();
$table->string('cardnum')->nullable();
$table->string('name_on_card')->nullable();
$table->string('issuing_bank')->nullable();
$table->string('card_type')->nullable();
$table->timestamps();
});
}
|
Run the migrations.
@return void
|
entailment
|
public function redirectTo($url, $parameters = [], $secure = null)
{
$this->url = url($url, $parameters, $secure);
return $this;
}
|
Set Redirect URL.
@param $url
@param array $parameters
@param null $secure
@return $this
|
entailment
|
public function redirectAction($action, $parameters = [], $absolute = true)
{
$this->url = action($action, $parameters, $absolute);
return $this;
}
|
Set Redirect Action.
@param $action
@param array|null $parameters
@param bool $absolute
@return $this
|
entailment
|
public function redirectRoute($route, $parameters = [], $absolute = true)
{
$this->url = route($route, $parameters, $absolute);
return $this;
}
|
Set Redirect Action.
@param $route
@param array|null $parameters
@param bool $absolute
@return $this
|
entailment
|
public function payment(Request $request)
{
$payment = (new Processor($request))->process();
Session::put('tzsk_payu_data.payment', $payment);
return redirect()->to(base64_decode($request->callback));
}
|
After payment it will return here.
@param Request $request
@return \Illuminate\Http\RedirectResponse
|
entailment
|
public function fire()
{
$name = $this->argument('name');
$force = $this->option('force');
$basePath = realpath(__DIR__ . '/../../..');
$namespace = config('admin-generator.namespace');
$engine = config("admin-generator.instances.{$name}.engine");
if ( ! $namespace) {
$this->error("The config 'namespace' in 'config/admin-generator.php' can not be empty, general set it to 'admin'");
exit;
}
if ( ! $name) {
$this->error('The name can not be empty');
exit;
}
if ( ! config("admin-generator.instances.{$name}")) {
$this->warn("The config of instance '{$name}' is not exist, check the typo or add it to config/admin-generator.php first");
exit;
}
if ( ! $engine) {
$this->warn("The engine option is empty, use --engine");
exit;
}
if ( ! is_dir($basePath . "/engines/{$engine}")) {
$this->warn("The engine '$engine' is not support.");
exit;
}
/**
*
*/
$finder = new Finder();
$path = $basePath . "/engines/{$engine}";
$copies = [ ];
$s = DIRECTORY_SEPARATOR;
foreach ($finder->name('*')->ignoreDotFiles(false)->in($path) as $file) {
/**
* @var \SplFileInfo $file
*/
if ($file->isFile()) {
$relativePath = str_replace($basePath . "{$s}engines{$s}{$engine}{$s}", '', $file->getRealPath());
$dest = base_path("resources{$s}" . $relativePath);
$dest = $this->replaceKeyword($dest);
if (is_file($dest) && ! $force) {
$this->warn(sprintf("The file '%s' exists, use '--force' option to overwrite it.", str_replace(base_path(), '', $dest)));
exit;
}
$copies[] = [ $file->getRealPath(), $dest ];
}
}
foreach ($copies as $copy) {
if ( ! is_dir(dirname($copy[1]))) {
mkdir(dirname($copy[1]), 0755, true);
}
$this->info('Copy file to: ' . str_replace(base_path(), '', $copy[1]));
File::copy($copy[0], $copy[1]);
}
$this->warn("Done! run 'gulp default && gulp watch' to generate assets");
}
|
Execute the console command.
@return mixed
|
entailment
|
public function boot()
{
$this->publishes([ realpath(__DIR__ . '/../config/admin-generator.php') => config_path('admin-generator.php') ], 'config');
$templatePath = $this->getTemplatePath();
$this->publishes([ realpath(__DIR__ . '/../templates') => $templatePath ], 'templates');
}
|
Perform post-registration booting of services.
@return void
|
entailment
|
public function register()
{
$this->app->singleton('le-admin.command.instance.new', function ($app) {
return $app->make('Lokielse\AdminGenerator\Console\Commands\CreateInstanceCommand');
});
$this->app->singleton('le-admin.command.entity.new', function ($app) {
return $app->make('Lokielse\AdminGenerator\Console\Commands\CreateEntityCommand');
});
$this->commands([
'le-admin.command.instance.new',
'le-admin.command.entity.new'
]);
}
|
Register any package services.
@return void
|
entailment
|
public function fire()
{
$instance = $this->argument('instance');
$template = $this->option('template');
$force = $this->option('force');
$merge = $this->option('merge');
$namespace = config('admin-generator.namespace');
$engine = config("admin-generator.instances.{$instance}.engine");
if ( ! $namespace) {
$this->error("The config 'namespace' in 'config/admin-generator.php' can not be empty, general set it to 'console'");
exit;
}
if ( ! config("admin-generator.instances.{$instance}")) {
$this->warn("The instance '{$instance}' is not exist, check the typo or add it to config/admin-generator.php first");
exit;
}
if ( ! $engine) {
$this->warn("The engine of instance '{$instance}' is not exist, check the typo or add it to config/admin-generator.php first");
}
$templates = $this->getTemplates($template, $merge, $engine);
$files = $this->getMergedFiles($templates, $engine);
$filesystem = new Filesystem();
foreach ($files as $src) {
$destName = $this->getFileDest($src, $engine);
$destName = $this->replaceKeyword($destName);
if (is_file($destName) && ! $force) {
$this->error(sprintf("The file %s is already exist, use option '--force' to override it", str_replace(base_path() . '/', '', $destName)));
exit;
} else {
$this->info(sprintf("Copying file to %s", str_replace(base_path() . '/', '', $destName)));
}
$content = $filesystem->get($src);
$replaced = $this->replaceKeyword($content);
$filesystem->put($destName, $replaced);
}
$this->warn('Done! Please config route and menu in app.coffee and MenuController.coffee');
}
|
Execute the console command.
@return mixed
|
entailment
|
protected function getTemplates($template, $merge)
{
$templates = explode(',', $template);
if ($merge) {
array_unshift($templates, 'default');
}
$templates = array_unique($templates);
return $templates;
}
|
@param $template
@param $merge
@return array
@internal param $engine
|
entailment
|
public function compress_image(){
//Send image array
$array_img_types = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
$new_image = null;
$last_char = null;
$image_extension = null;
$destination_extension = null;
$png_compression = null;
$maxsize = 5245330;
try{
//If not found the file
if(empty($this->file_url) && !file_exists($this->file_url)){
throw new Exception('Please inform the image!');
return false;
}
//Get image width, height, mimetype, etc..
$image_data = getimagesize($this->file_url);
//Set MimeType on variable
$image_mime = $image_data['mime'];
//Verifiy if the file is a image
if(!in_array($image_mime, $array_img_types)){
throw new Exception('Please send a image!');
return false;
}
//Get file size
$image_size = filesize($this->file_url);
//if image size is bigger than 5mb
if($image_size >= $maxsize){
throw new Exception('Please send a imagem smaller than 5mb!');
return false;
}
//If not found the destination
if(empty($this->new_name_image)){
throw new Exception('Please inform the destination name of image!');
return false;
}
//If not found the quality
if(empty($this->quality)){
throw new Exception('Please inform the quality!');
return false;
}
//If not found the png quality
$png_compression = (!empty($this->pngQuality)) ? $this->pngQuality : 9 ;
$image_extension = pathinfo($this->file_url, PATHINFO_EXTENSION);
//Verify if is sended a destination file name with extension
$destination_extension = pathinfo($this->new_name_image, PATHINFO_EXTENSION);
//if empty
if(empty($destination_extension)){
$this->new_name_image = $this->new_name_image.'.'.$image_extension;
}
//Verify if folder destination isn´t empty
if(!empty($this->destination)){
//And verify the last one element of value
$last_char = substr($this->destination, -1);
if($last_char !== '/'){
$this->destination = $this->destination.'/';
}
}
//Switch to find the file type
switch ($image_mime){
//if is JPG and siblings
case 'image/jpeg':
case 'image/pjpeg':
//Create a new jpg image
$new_image = imagecreatefromjpeg($this->file_url);
imagejpeg($new_image, $this->destination.$this->new_name_image, $this->quality);
break;
//if is PNG and siblings
case 'image/png':
case 'image/x-png':
//Create a new png image
$new_image = imagecreatefrompng('conteudo/'.$this->file_url);
imagealphablending($new_image , false);
imagesavealpha($new_image , true);
imagepng($new_image, $this->destination.$this->new_name_image, $png_compression);
break;
// if is GIF
case 'image/gif':
//Create a new gif image
$new_image = imagecreatefromgif('conteudo/'.$this->file_url);
imagealphablending($new_image, false);
imagesavealpha($new_image, true);
imagegif($new_image, $this->destination.$this->new_name_image);
}
} catch (Exception $ex) {
return $ex->getMessage();
}
//Return the new image resized
return $this->new_name_image;
}
|
Function to compress image
@return boolean
@throws Exception
|
entailment
|
public static function init() {
add_action( 'load-nav-menus.php', array( __CLASS__, '_load_nav_menus' ) );
add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, '_filter_wp_edit_nav_menu_walker' ), 99 );
add_filter( 'wp_nav_menu_item_custom_fields', array( __CLASS__, '_fields' ), 10, 4 );
add_filter( 'manage_nav-menus_columns', array( __CLASS__, '_columns' ), 99 );
add_action( 'wp_update_nav_menu_item', array( __CLASS__, '_save' ), 10, 3 );
add_filter( 'icon_picker_type_props', array( __CLASS__, '_add_extra_type_props_data' ), 10, 3 );
}
|
Initialize class
@since 0.1.0
|
entailment
|
protected static function _get_menu_item_fields( $meta ) {
$fields = array_merge(
array(
array(
'id' => 'type',
'label' => __( 'Type', 'menu-icons' ),
'value' => $meta['type'],
),
array(
'id' => 'icon',
'label' => __( 'Icon', 'menu-icons' ),
'value' => $meta['icon'],
),
),
Menu_Icons_Settings::get_settings_fields( $meta )
);
return $fields;
}
|
Get menu item setting fields
@since 0.9.0
@access protected
@param array $meta Menu item meta value.
@return array
|
entailment
|
public static function _fields( $id, $item, $depth, $args ) {
$input_id = sprintf( 'menu-icons-%d', $item->ID );
$input_name = sprintf( 'menu-icons[%d]', $item->ID );
$menu_settings = Menu_Icons_Settings::get_menu_settings( Menu_Icons_Settings::get_current_menu_id() );
$meta = Menu_Icons_Meta::get( $item->ID, $menu_settings );
$fields = self::_get_menu_item_fields( $meta );
?>
<div class="field-icon description-wide menu-icons-wrap" data-id="<?php echo json_encode( $item->ID ); ?>">
<?php
/**
* Allow plugins/themes to inject HTML before menu icons' fields
*
* @param object $item Menu item data object.
* @param int $depth Nav menu depth.
* @param array $args Menu item args.
* @param int $id Nav menu ID.
*
*/
do_action( 'menu_icons_before_fields', $item, $depth, $args, $id );
?>
<p class="description submitbox">
<label><?php esc_html_e( 'Icon:', 'menu-icons' ) ?></label>
<?php printf( '<a class="_select">%s</a>', esc_html__( 'Select', 'menu-icons' ) ); ?>
<?php printf( '<a class="_remove submitdelete hidden">%s</a>', esc_html__( 'Remove', 'menu-icons' ) ); ?>
</p>
<div class="_settings hidden">
<?php
foreach ( $fields as $field ) {
printf(
'<label>%1$s: <input type="text" name="%2$s" class="_mi-%3$s" value="%4$s" /></label><br />',
esc_html( $field['label'] ),
esc_attr( "{$input_name}[{$field['id']}]" ),
esc_attr( $field['id'] ),
esc_attr( $field['value'] )
);
}
// The fields below will not be saved. They're only used for the preview.
printf( '<input type="hidden" class="_mi-url" value="%s" />', esc_attr( $meta['url'] ) );
?>
</div>
<?php
/**
* Allow plugins/themes to inject HTML after menu icons' fields
*
* @param object $item Menu item data object.
* @param int $depth Nav menu depth.
* @param array $args Menu item args.
* @param int $id Nav menu ID.
*
*/
do_action( 'menu_icons_after_fields', $item, $depth, $args, $id );
?>
</div>
<?php
}
|
Print fields
@since 0.1.0
@access protected
@uses add_action() Calls 'menu_icons_before_fields' hook
@uses add_action() Calls 'menu_icons_after_fields' hook
@wp_hook action menu_item_custom_fields
@param object $item Menu item data object.
@param int $depth Nav menu depth.
@param array $args Menu item args.
@param int $id Nav menu ID.
@return string Form fields
|
entailment
|
public static function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
$screen = get_current_screen();
if ( ! $screen instanceof WP_Screen || 'nav-menus' !== $screen->id ) {
return;
}
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
// Sanitize
if ( ! empty( $_POST['menu-icons'][ $menu_item_db_id ] ) ) {
$value = array_map(
'sanitize_text_field',
wp_unslash( (array) $_POST['menu-icons'][ $menu_item_db_id ] )
);
} else {
$value = array();
}
Menu_Icons_Meta::update( $menu_item_db_id, $value );
}
|
Save menu item's icons metadata
@since 0.1.0
@access protected
@wp_hook action wp_update_nav_menu_item
@link http://codex.wordpress.org/Plugin_API/Action_Reference/wp_update_nav_menu_item
@param int $menu_id Nav menu ID.
@param int $menu_item_db_id Menu item ID.
@param array $menu_item_args Menu item data.
|
entailment
|
public static function _media_templates() {
$id_prefix = 'tmpl-menu-icons';
// Deprecated.
$templates = apply_filters( 'menu_icons_media_templates', array() );
if ( ! empty( $templates ) ) {
if ( WP_DEBUG ) {
_deprecated_function( 'menu_icons_media_templates', '0.9.0', 'menu_icons_js_templates' );
}
foreach ( $templates as $key => $template ) {
$id = sprintf( '%s-%s', $id_prefix, $key );
self::_print_tempate( $id, $template );
}
}
require_once dirname( __FILE__ ) . '/media-template.php';
}
|
Get and print media templates from all types
@since 0.2.0
@since 0.9.0 Deprecate menu_icons_media_templates filter.
@wp_hook action print_media_templates
|
entailment
|
public static function _add_extra_type_props_data( $props, $id, $type ) {
$settings_fields = array(
'hide_label',
'position',
'vertical_align',
);
if ( 'Font' === $props['controller'] ) {
$settings_fields[] = 'font_size';
}
switch ( $id ) {
case 'image':
$settings_fields[] = 'image_size';
break;
case 'svg':
$settings_fields[] = 'svg_width';
break;
}
$props['data']['settingsFields'] = $settings_fields;
return $props;
}
|
Add extra icon type properties data
@since 0.9.0
@wp_hook action icon_picker_type_props
@param array $props Icon type properties.
@param string $id Icon type ID.
@param Icon_Picker_Type $type Icon_Picker_Type object.
@return array
|
entailment
|
public static function init() {
/**
* Allow themes/plugins to override the default settings
*
* @since 0.9.0
*
* @param array $default_settings Default settings.
*/
self::$defaults = apply_filters( 'menu_icons_settings_defaults', self::$defaults );
self::$settings = get_option( 'menu-icons', self::$defaults );
foreach ( self::$settings as $key => &$value ) {
if ( 'global' === $key ) {
// Remove unregistered icon types.
$value['icon_types'] = array_values(
array_intersect(
array_keys( Menu_Icons::get( 'types' ) ),
array_filter( (array) $value['icon_types'] )
)
);
} else {
// Backward-compatibility.
if ( isset( $value['width'] ) && ! isset( $value['svg_width'] ) ) {
$value['svg_width'] = $value['width'];
}
unset( $value['width'] );
}
}
unset( $value );
/**
* Allow themes/plugins to override the settings
*
* @since 0.9.0
*
* @param array $settings Menu Icons settings.
*/
self::$settings = apply_filters( 'menu_icons_settings', self::$settings );
if ( self::is_menu_icons_disabled_for_menu() ) {
return;
}
if ( ! empty( self::$settings['global']['icon_types'] ) ) {
require_once Menu_Icons::get( 'dir' ) . 'includes/picker.php';
Menu_Icons_Picker::init();
self::$script_deps[] = 'icon-picker';
}
add_action( 'load-nav-menus.php', array( __CLASS__, '_load_nav_menus' ), 1 );
add_action( 'wp_ajax_menu_icons_update_settings', array( __CLASS__, '_ajax_menu_icons_update_settings' ) );
}
|
Settings init
@since 0.3.0
|
entailment
|
public static function is_menu_icons_disabled_for_menu( $menu_id = 0 ) {
if ( empty( $menu_id ) ) {
$menu_id = self::get_current_menu_id();
}
// When we're creating a new menu or the recently edited menu
// could not be found.
if ( empty( $menu_id ) ) {
return true;
}
$menu_settings = self::get_menu_settings( $menu_id );
$is_disabled = ! empty( $menu_settings['disabled'] );
return $is_disabled;
}
|
Check if menu icons is disabled for a menu
@since 0.8.0
@param int $menu_id Menu ID. Defaults to current menu being edited.
@return bool
|
entailment
|
public static function get_current_menu_id() {
global $nav_menu_selected_id;
if ( ! empty( $nav_menu_selected_id ) ) {
return $nav_menu_selected_id;
}
if ( is_admin() && isset( $_REQUEST['menu'] ) ) {
$menu_id = absint( $_REQUEST['menu'] );
} else {
$menu_id = absint( get_user_option( 'nav_menu_recently_edited' ) );
}
return $menu_id;
}
|
Get ID of menu being edited
@since 0.7.0
@since 0.8.0 Get the recently edited menu from user option.
@return int
|
entailment
|
public static function get_menu_settings( $menu_id ) {
$menu_settings = self::get( sprintf( 'menu_%d', $menu_id ) );
$menu_settings = apply_filters( 'menu_icons_menu_settings', $menu_settings, $menu_id );
if ( ! is_array( $menu_settings ) ) {
$menu_settings = array();
}
return $menu_settings;
}
|
Get menu settings
@since 0.3.0
@param int $menu_id
@return array
|
entailment
|
public static function _load_nav_menus() {
add_action( 'admin_enqueue_scripts', array( __CLASS__, '_enqueue_assets' ), 99 );
/**
* Allow settings meta box to be disabled.
*
* @since 0.4.0
*
* @param bool $disabled Defaults to FALSE.
*/
$settings_disabled = apply_filters( 'menu_icons_disable_settings', false );
if ( true === $settings_disabled ) {
return;
}
self::_maybe_update_settings();
self::_add_settings_meta_box();
add_action( 'admin_notices', array( __CLASS__, '_admin_notices' ) );
}
|
Prepare wp-admin/nav-menus.php page
@since 0.3.0
@wp_hook action load-nav-menus.php
|
entailment
|
public static function _maybe_update_settings() {
if ( ! empty( $_POST['menu-icons']['settings'] ) ) {
check_admin_referer( self::UPDATE_KEY, self::UPDATE_KEY );
$redirect_url = self::_update_settings( $_POST['menu-icons']['settings'] ); // Input var okay.
wp_redirect( $redirect_url );
} elseif ( ! empty( $_REQUEST[ self::RESET_KEY ] ) ) {
check_admin_referer( self::RESET_KEY, self::RESET_KEY );
wp_redirect( self::_reset_settings() );
}
}
|
Update settings
@since 0.3.0
|
entailment
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.