repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gdbots/ncr-php | src/NcrLazyLoader.php | NcrLazyLoader.hasNodeRef | public function hasNodeRef(NodeRef $nodeRef): bool
{
if (null === $this->getNodeBatchRequest) {
return false;
}
return $this->getNodeBatchRequest->isInSet('node_refs', $nodeRef);
} | php | public function hasNodeRef(NodeRef $nodeRef): bool
{
if (null === $this->getNodeBatchRequest) {
return false;
}
return $this->getNodeBatchRequest->isInSet('node_refs', $nodeRef);
} | [
"public",
"function",
"hasNodeRef",
"(",
"NodeRef",
"$",
"nodeRef",
")",
":",
"bool",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"getNodeBatchRequest",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"getNodeBatchRequest",
"->",
... | Returns true if the given NodeRef is in the pending lazy load request.
@param NodeRef $nodeRef
@return bool | [
"Returns",
"true",
"if",
"the",
"given",
"NodeRef",
"is",
"in",
"the",
"pending",
"lazy",
"load",
"request",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/NcrLazyLoader.php#L45-L52 | train |
gdbots/ncr-php | src/NcrLazyLoader.php | NcrLazyLoader.removeNodeRefs | public function removeNodeRefs(array $nodeRefs): void
{
if (null === $this->getNodeBatchRequest) {
return;
}
$this->getNodeBatchRequest->removeFromSet('node_refs', $nodeRefs);
} | php | public function removeNodeRefs(array $nodeRefs): void
{
if (null === $this->getNodeBatchRequest) {
return;
}
$this->getNodeBatchRequest->removeFromSet('node_refs', $nodeRefs);
} | [
"public",
"function",
"removeNodeRefs",
"(",
"array",
"$",
"nodeRefs",
")",
":",
"void",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"getNodeBatchRequest",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"getNodeBatchRequest",
"->",
"removeFromSet",
... | Removes an array of NodeRefs from the deferrered request.
@param NodeRef[] $nodeRefs | [
"Removes",
"an",
"array",
"of",
"NodeRefs",
"from",
"the",
"deferrered",
"request",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/NcrLazyLoader.php#L138-L145 | train |
gdbots/ncr-php | src/NcrLazyLoader.php | NcrLazyLoader.flush | public function flush(): void
{
if (null === $this->getNodeBatchRequest) {
return;
}
if (!$this->getNodeBatchRequest->has('node_refs')) {
return;
}
try {
$request = $this->getNodeBatchRequest;
$this->getNodeBatchRequest = null;
$this->pbjx->request($request);
} catch (\Throwable $e) {
$this->logger->error(
sprintf('%s::NcrLazyLoader::flush() could not complete.', ClassUtils::getShortName($e)),
['exception' => $e, 'pbj' => $request->toArray()]
);
}
} | php | public function flush(): void
{
if (null === $this->getNodeBatchRequest) {
return;
}
if (!$this->getNodeBatchRequest->has('node_refs')) {
return;
}
try {
$request = $this->getNodeBatchRequest;
$this->getNodeBatchRequest = null;
$this->pbjx->request($request);
} catch (\Throwable $e) {
$this->logger->error(
sprintf('%s::NcrLazyLoader::flush() could not complete.', ClassUtils::getShortName($e)),
['exception' => $e, 'pbj' => $request->toArray()]
);
}
} | [
"public",
"function",
"flush",
"(",
")",
":",
"void",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"getNodeBatchRequest",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getNodeBatchRequest",
"->",
"has",
"(",
"'node_refs'",
")",... | Processes the deferrered request which should populate the
NcrCache once complete. At least for any nodes that exist. | [
"Processes",
"the",
"deferrered",
"request",
"which",
"should",
"populate",
"the",
"NcrCache",
"once",
"complete",
".",
"At",
"least",
"for",
"any",
"nodes",
"that",
"exist",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/NcrLazyLoader.php#L159-L179 | train |
gdbots/ncr-php | src/Search/Elastica/QueryFactory.php | QueryFactory.filterStatuses | protected function filterStatuses(SearchNodesRequest $request, Query\BoolQuery $query): void
{
if (!$request->has('statuses')) {
return;
}
$statuses = array_map('strval', $request->get('statuses'));
$query->addFilter(new Query\Terms('status', $statuses));
} | php | protected function filterStatuses(SearchNodesRequest $request, Query\BoolQuery $query): void
{
if (!$request->has('statuses')) {
return;
}
$statuses = array_map('strval', $request->get('statuses'));
$query->addFilter(new Query\Terms('status', $statuses));
} | [
"protected",
"function",
"filterStatuses",
"(",
"SearchNodesRequest",
"$",
"request",
",",
"Query",
"\\",
"BoolQuery",
"$",
"query",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"request",
"->",
"has",
"(",
"'statuses'",
")",
")",
"{",
"return",
";",
"}",... | Add the "statuses" into one terms query as it's more efficient.
@link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html
@param SearchNodesRequest $request
@param Query\BoolQuery $query | [
"Add",
"the",
"statuses",
"into",
"one",
"terms",
"query",
"as",
"it",
"s",
"more",
"efficient",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Search/Elastica/QueryFactory.php#L65-L73 | train |
gdbots/ncr-php | src/NcrRequestInterceptor.php | NcrRequestInterceptor.enrichGetNodeRequest | public function enrichGetNodeRequest(PbjxEvent $pbjxEvent): void
{
$request = $pbjxEvent->getMessage();
if ($request->has('node_ref')
|| $request->get('consistent_read')
|| !$request->has('qname')
|| !$request->has('slug')
) {
return;
}
$qname = SchemaQName::fromString($request->get('qname'));
$cacheKey = $this->getSlugCacheKey($qname, $request->get('slug'));
$cacheItem = $this->cache->getItem($cacheKey);
if (!$cacheItem->isHit()) {
$this->cacheItems[$cacheKey] = $cacheItem;
return;
}
try {
$nodeRef = NodeRef::fromString($cacheItem->get());
if ($nodeRef->getQName() === $qname) {
$request->set('node_ref', $nodeRef);
}
} catch (\Throwable $e) {
}
} | php | public function enrichGetNodeRequest(PbjxEvent $pbjxEvent): void
{
$request = $pbjxEvent->getMessage();
if ($request->has('node_ref')
|| $request->get('consistent_read')
|| !$request->has('qname')
|| !$request->has('slug')
) {
return;
}
$qname = SchemaQName::fromString($request->get('qname'));
$cacheKey = $this->getSlugCacheKey($qname, $request->get('slug'));
$cacheItem = $this->cache->getItem($cacheKey);
if (!$cacheItem->isHit()) {
$this->cacheItems[$cacheKey] = $cacheItem;
return;
}
try {
$nodeRef = NodeRef::fromString($cacheItem->get());
if ($nodeRef->getQName() === $qname) {
$request->set('node_ref', $nodeRef);
}
} catch (\Throwable $e) {
}
} | [
"public",
"function",
"enrichGetNodeRequest",
"(",
"PbjxEvent",
"$",
"pbjxEvent",
")",
":",
"void",
"{",
"$",
"request",
"=",
"$",
"pbjxEvent",
"->",
"getMessage",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"has",
"(",
"'node_ref'",
")",
"||",
"$",
... | Enrich the request with a node_ref if possible to minimize
the number of lookups against the slug secondary index.
@param PbjxEvent $pbjxEvent | [
"Enrich",
"the",
"request",
"with",
"a",
"node_ref",
"if",
"possible",
"to",
"minimize",
"the",
"number",
"of",
"lookups",
"against",
"the",
"slug",
"secondary",
"index",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/NcrRequestInterceptor.php#L72-L99 | train |
gdbots/ncr-php | src/NcrCache.php | NcrCache.pruneNodeCache | private function pruneNodeCache(): void
{
if ($this->maxItems > 0 && count($this->nodes) > $this->maxItems) {
$this->nodes = array_slice($this->nodes, (int)($this->maxItems * 0.2), null, true);
}
} | php | private function pruneNodeCache(): void
{
if ($this->maxItems > 0 && count($this->nodes) > $this->maxItems) {
$this->nodes = array_slice($this->nodes, (int)($this->maxItems * 0.2), null, true);
}
} | [
"private",
"function",
"pruneNodeCache",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"maxItems",
">",
"0",
"&&",
"count",
"(",
"$",
"this",
"->",
"nodes",
")",
">",
"$",
"this",
"->",
"maxItems",
")",
"{",
"$",
"this",
"->",
"nodes",
... | Prunes node cache by removing 20% of the cache if it is full. | [
"Prunes",
"node",
"cache",
"by",
"removing",
"20%",
"of",
"the",
"cache",
"if",
"it",
"is",
"full",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/NcrCache.php#L220-L225 | train |
starweb/starlit-db | src/Db.php | Db.executeQuery | protected function executeQuery($sql, array $parameters = [])
{
$this->connect();
$dbParameters = $this->prepareParameters($parameters);
try {
$pdoStatement = $this->pdo->prepare($sql);
$pdoStatement->execute($dbParameters);
return $pdoStatement;
} catch (PDOException $e) {
throw new QueryException($e, $sql, $dbParameters);
}
} | php | protected function executeQuery($sql, array $parameters = [])
{
$this->connect();
$dbParameters = $this->prepareParameters($parameters);
try {
$pdoStatement = $this->pdo->prepare($sql);
$pdoStatement->execute($dbParameters);
return $pdoStatement;
} catch (PDOException $e) {
throw new QueryException($e, $sql, $dbParameters);
}
} | [
"protected",
"function",
"executeQuery",
"(",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"dbParameters",
"=",
"$",
"this",
"->",
"prepareParameters",
"(",
"$",
"parameters",
"... | Creates and executes a PDO statement.
@param string $sql
@param array $parameters
@return PDOStatement | [
"Creates",
"and",
"executes",
"a",
"PDO",
"statement",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/Db.php#L189-L202 | train |
starweb/starlit-db | src/Db.php | Db.exec | public function exec($sql, array $parameters = [])
{
$statement = $this->executeQuery($sql, $parameters);
return $statement->rowCount();
} | php | public function exec($sql, array $parameters = [])
{
$statement = $this->executeQuery($sql, $parameters);
return $statement->rowCount();
} | [
"public",
"function",
"exec",
"(",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"executeQuery",
"(",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"statement",
"->",
... | Execute an SQL statement and return the number of affected rows.
@param string $sql
@param array $parameters
@return int The number of rows affected | [
"Execute",
"an",
"SQL",
"statement",
"and",
"return",
"the",
"number",
"of",
"affected",
"rows",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/Db.php#L211-L216 | train |
starweb/starlit-db | src/Db.php | Db.fetchRow | public function fetchRow($sql, array $parameters = [], $indexedKeys = false)
{
$statement = $this->executeQuery($sql, $parameters);
return $statement->fetch($indexedKeys ? PDO::FETCH_NUM : PDO::FETCH_ASSOC);
} | php | public function fetchRow($sql, array $parameters = [], $indexedKeys = false)
{
$statement = $this->executeQuery($sql, $parameters);
return $statement->fetch($indexedKeys ? PDO::FETCH_NUM : PDO::FETCH_ASSOC);
} | [
"public",
"function",
"fetchRow",
"(",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"indexedKeys",
"=",
"false",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"executeQuery",
"(",
"$",
"sql",
",",
"$",
"parameters",
")"... | Execute an SQL statement and return the first row.
@param string $sql
@param array $parameters
@param bool $indexedKeys
@return array|false | [
"Execute",
"an",
"SQL",
"statement",
"and",
"return",
"the",
"first",
"row",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/Db.php#L226-L231 | train |
starweb/starlit-db | src/Db.php | Db.fetchRows | public function fetchRows($sql, array $parameters = [], $indexedKeys = false)
{
$statement = $this->executeQuery($sql, $parameters);
return $statement->fetchAll($indexedKeys ? PDO::FETCH_NUM : PDO::FETCH_ASSOC);
} | php | public function fetchRows($sql, array $parameters = [], $indexedKeys = false)
{
$statement = $this->executeQuery($sql, $parameters);
return $statement->fetchAll($indexedKeys ? PDO::FETCH_NUM : PDO::FETCH_ASSOC);
} | [
"public",
"function",
"fetchRows",
"(",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"indexedKeys",
"=",
"false",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"executeQuery",
"(",
"$",
"sql",
",",
"$",
"parameters",
")... | Execute an SQL statement and return all rows as an array.
@param string $sql
@param array $parameters
@param bool $indexedKeys
@return array | [
"Execute",
"an",
"SQL",
"statement",
"and",
"return",
"all",
"rows",
"as",
"an",
"array",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/Db.php#L241-L246 | train |
starweb/starlit-db | src/Db.php | Db.fetchValue | public function fetchValue($sql, array $parameters = [])
{
$statement = $this->executeQuery($sql, $parameters);
return $statement->fetchColumn(0);
} | php | public function fetchValue($sql, array $parameters = [])
{
$statement = $this->executeQuery($sql, $parameters);
return $statement->fetchColumn(0);
} | [
"public",
"function",
"fetchValue",
"(",
"$",
"sql",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"executeQuery",
"(",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"statement",
"-... | Execute an SQL statement and return the first column of the first row.
@param string $sql
@param array $parameters
@return string|false | [
"Execute",
"an",
"SQL",
"statement",
"and",
"return",
"the",
"first",
"column",
"of",
"the",
"first",
"row",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/Db.php#L255-L260 | train |
starweb/starlit-db | src/Db.php | Db.prepareParameters | protected function prepareParameters(array $parameters = [])
{
foreach ($parameters as &$parameterValue) {
if (is_bool($parameterValue)) {
$parameterValue = (int) $parameterValue;
} elseif ($parameterValue instanceof \DateTimeInterface) {
$parameterValue = $parameterValue->format('Y-m-d H:i:s');
} elseif (!is_scalar($parameterValue) && $parameterValue !== null) {
throw new \InvalidArgumentException(
sprintf('Invalid db parameter type "%s"', gettype($parameterValue))
);
}
}
unset($parameterValue);
return $parameters;
} | php | protected function prepareParameters(array $parameters = [])
{
foreach ($parameters as &$parameterValue) {
if (is_bool($parameterValue)) {
$parameterValue = (int) $parameterValue;
} elseif ($parameterValue instanceof \DateTimeInterface) {
$parameterValue = $parameterValue->format('Y-m-d H:i:s');
} elseif (!is_scalar($parameterValue) && $parameterValue !== null) {
throw new \InvalidArgumentException(
sprintf('Invalid db parameter type "%s"', gettype($parameterValue))
);
}
}
unset($parameterValue);
return $parameters;
} | [
"protected",
"function",
"prepareParameters",
"(",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"parameters",
"as",
"&",
"$",
"parameterValue",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"parameterValue",
")",
")",
"{",
"$",
... | Prepare parameters for database use.
@param array $parameters
@return array | [
"Prepare",
"parameters",
"for",
"database",
"use",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/Db.php#L293-L309 | train |
gdbots/ncr-php | src/Repository/DynamoDb/NodeTable.php | NodeTable.create | final public function create(DynamoDbClient $client, string $tableName): void
{
try {
$client->describeTable(['TableName' => $tableName]);
return;
} catch (DynamoDbException $e) {
// table doesn't exist, create it below
}
$this->loadIndexes();
$attributes = [];
$indexes = [];
foreach ($this->gsi as $gsi) {
foreach ($gsi->getKeyAttributes() as $definition) {
$attributes[$definition['AttributeName']] = $definition;
}
$indexName = $gsi->getName();
$indexes[$indexName] = [
'IndexName' => $indexName,
'KeySchema' => [
['AttributeName' => $gsi->getHashKeyName(), 'KeyType' => 'HASH'],
],
'Projection' => $gsi->getProjection() ?: ['ProjectionType' => 'KEYS_ONLY'],
'ProvisionedThroughput' => $this->getDefaultProvisionedThroughput(),
];
if ($gsi->getRangeKeyName()) {
$indexes[$indexName]['KeySchema'][] = ['AttributeName' => $gsi->getRangeKeyName(), 'KeyType' => 'RANGE'];
}
}
$attributes[self::HASH_KEY_NAME] = ['AttributeName' => self::HASH_KEY_NAME, 'AttributeType' => 'S'];
$attributes = array_values($attributes);
$indexes = array_values($indexes);
try {
$client->createTable([
'TableName' => $tableName,
'AttributeDefinitions' => $attributes,
'KeySchema' => [
['AttributeName' => self::HASH_KEY_NAME, 'KeyType' => 'HASH'],
],
'GlobalSecondaryIndexes' => $indexes,
'StreamSpecification' => [
'StreamEnabled' => true,
'StreamViewType' => 'NEW_AND_OLD_IMAGES',
],
'ProvisionedThroughput' => $this->getDefaultProvisionedThroughput(),
]);
$client->waitUntil('TableExists', ['TableName' => $tableName]);
} catch (\Throwable $e) {
throw new RepositoryOperationFailed(
sprintf(
'%s::Unable to create table [%s] in region [%s].',
ClassUtils::getShortName($this),
$tableName,
$client->getRegion()
),
Code::INTERNAL,
$e
);
}
} | php | final public function create(DynamoDbClient $client, string $tableName): void
{
try {
$client->describeTable(['TableName' => $tableName]);
return;
} catch (DynamoDbException $e) {
// table doesn't exist, create it below
}
$this->loadIndexes();
$attributes = [];
$indexes = [];
foreach ($this->gsi as $gsi) {
foreach ($gsi->getKeyAttributes() as $definition) {
$attributes[$definition['AttributeName']] = $definition;
}
$indexName = $gsi->getName();
$indexes[$indexName] = [
'IndexName' => $indexName,
'KeySchema' => [
['AttributeName' => $gsi->getHashKeyName(), 'KeyType' => 'HASH'],
],
'Projection' => $gsi->getProjection() ?: ['ProjectionType' => 'KEYS_ONLY'],
'ProvisionedThroughput' => $this->getDefaultProvisionedThroughput(),
];
if ($gsi->getRangeKeyName()) {
$indexes[$indexName]['KeySchema'][] = ['AttributeName' => $gsi->getRangeKeyName(), 'KeyType' => 'RANGE'];
}
}
$attributes[self::HASH_KEY_NAME] = ['AttributeName' => self::HASH_KEY_NAME, 'AttributeType' => 'S'];
$attributes = array_values($attributes);
$indexes = array_values($indexes);
try {
$client->createTable([
'TableName' => $tableName,
'AttributeDefinitions' => $attributes,
'KeySchema' => [
['AttributeName' => self::HASH_KEY_NAME, 'KeyType' => 'HASH'],
],
'GlobalSecondaryIndexes' => $indexes,
'StreamSpecification' => [
'StreamEnabled' => true,
'StreamViewType' => 'NEW_AND_OLD_IMAGES',
],
'ProvisionedThroughput' => $this->getDefaultProvisionedThroughput(),
]);
$client->waitUntil('TableExists', ['TableName' => $tableName]);
} catch (\Throwable $e) {
throw new RepositoryOperationFailed(
sprintf(
'%s::Unable to create table [%s] in region [%s].',
ClassUtils::getShortName($this),
$tableName,
$client->getRegion()
),
Code::INTERNAL,
$e
);
}
} | [
"final",
"public",
"function",
"create",
"(",
"DynamoDbClient",
"$",
"client",
",",
"string",
"$",
"tableName",
")",
":",
"void",
"{",
"try",
"{",
"$",
"client",
"->",
"describeTable",
"(",
"[",
"'TableName'",
"=>",
"$",
"tableName",
"]",
")",
";",
"retu... | Creates a DynamoDb table with the node schema.
@param DynamoDbClient $client
@param string $tableName
@throws RepositoryOperationFailed | [
"Creates",
"a",
"DynamoDb",
"table",
"with",
"the",
"node",
"schema",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Repository/DynamoDb/NodeTable.php#L50-L116 | train |
gdbots/ncr-php | src/Repository/DynamoDb/NodeTable.php | NodeTable.hasIndex | final public function hasIndex(string $alias): bool
{
$this->loadIndexes();
return isset($this->gsi[$alias]);
} | php | final public function hasIndex(string $alias): bool
{
$this->loadIndexes();
return isset($this->gsi[$alias]);
} | [
"final",
"public",
"function",
"hasIndex",
"(",
"string",
"$",
"alias",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"loadIndexes",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"gsi",
"[",
"$",
"alias",
"]",
")",
";",
"}"
] | Returns true if this NodeTable has the given index.
@see GlobalSecondaryIndex::getAlias()
@param string $alias
@return bool | [
"Returns",
"true",
"if",
"this",
"NodeTable",
"has",
"the",
"given",
"index",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Repository/DynamoDb/NodeTable.php#L156-L160 | train |
gdbots/ncr-php | src/Repository/DynamoDb/NodeTable.php | NodeTable.getIndex | final public function getIndex(string $alias): ?GlobalSecondaryIndex
{
$this->loadIndexes();
return $this->gsi[$alias] ?? null;
} | php | final public function getIndex(string $alias): ?GlobalSecondaryIndex
{
$this->loadIndexes();
return $this->gsi[$alias] ?? null;
} | [
"final",
"public",
"function",
"getIndex",
"(",
"string",
"$",
"alias",
")",
":",
"?",
"GlobalSecondaryIndex",
"{",
"$",
"this",
"->",
"loadIndexes",
"(",
")",
";",
"return",
"$",
"this",
"->",
"gsi",
"[",
"$",
"alias",
"]",
"??",
"null",
";",
"}"
] | Returns an index by its alias if it exists on this table.
@param string $alias
@return GlobalSecondaryIndex|null | [
"Returns",
"an",
"index",
"by",
"its",
"alias",
"if",
"it",
"exists",
"on",
"this",
"table",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Repository/DynamoDb/NodeTable.php#L169-L173 | train |
gdbots/ncr-php | src/Repository/DynamoDb/NodeTable.php | NodeTable.beforePutItem | final public function beforePutItem(array &$item, Node $node): void
{
$this->loadIndexes();
$this->addShardAttributes($item, $node);
if ($node instanceof Indexed) {
$item[NodeTable::INDEXED_KEY_NAME] = ['BOOL' => true];
}
foreach ($this->gsi as $gsi) {
$gsi->beforePutItem($item, $node);
}
$this->doBeforePutItem($item, $node);
} | php | final public function beforePutItem(array &$item, Node $node): void
{
$this->loadIndexes();
$this->addShardAttributes($item, $node);
if ($node instanceof Indexed) {
$item[NodeTable::INDEXED_KEY_NAME] = ['BOOL' => true];
}
foreach ($this->gsi as $gsi) {
$gsi->beforePutItem($item, $node);
}
$this->doBeforePutItem($item, $node);
} | [
"final",
"public",
"function",
"beforePutItem",
"(",
"array",
"&",
"$",
"item",
",",
"Node",
"$",
"node",
")",
":",
"void",
"{",
"$",
"this",
"->",
"loadIndexes",
"(",
")",
";",
"$",
"this",
"->",
"addShardAttributes",
"(",
"$",
"item",
",",
"$",
"no... | Calls all of the indexes on this table "beforePutItem" methods.
@param array $item
@param Node $node | [
"Calls",
"all",
"of",
"the",
"indexes",
"on",
"this",
"table",
"beforePutItem",
"methods",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Repository/DynamoDb/NodeTable.php#L181-L194 | train |
gdbots/ncr-php | src/Repository/DynamoDb/NodeTable.php | NodeTable.loadIndexes | private function loadIndexes(): void
{
if (null !== $this->gsi) {
return;
}
$this->gsi = [];
foreach ($this->getIndexes() as $gsi) {
$this->gsi[$gsi->getAlias()] = $gsi;
}
} | php | private function loadIndexes(): void
{
if (null !== $this->gsi) {
return;
}
$this->gsi = [];
foreach ($this->getIndexes() as $gsi) {
$this->gsi[$gsi->getAlias()] = $gsi;
}
} | [
"private",
"function",
"loadIndexes",
"(",
")",
":",
"void",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"gsi",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"gsi",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getIndexes",
"("... | Load the indexes for this table. | [
"Load",
"the",
"indexes",
"for",
"this",
"table",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Repository/DynamoDb/NodeTable.php#L250-L260 | train |
starweb/starlit-db | src/AbstractDbEntityFetcher.php | AbstractDbEntityFetcher.getLimitSql | protected function getLimitSql($limit, array $pageItem = [])
{
$limitSql = '';
if (!empty($limit) || !empty($pageItem)) {
$limitSql = 'LIMIT ';
if (!empty($pageItem)) {
list($pageNo, $rowsPerPage) = $pageItem;
$pageNo = (int) $pageNo;
if ($pageNo < 1) {
throw new \InvalidArgumentException("Invalid pagination page number \"{$pageNo}\"");
}
$rowsPerPage = (int) $rowsPerPage;
// Offset example: "10" skips the first 10 rows, start showing the 11th
$offset = ($pageNo - 1) * $rowsPerPage;
$limitSql .= sprintf('%d, %d', $offset, $rowsPerPage);
} else {
$limitSql .= (int) $limit;
}
}
return $limitSql;
} | php | protected function getLimitSql($limit, array $pageItem = [])
{
$limitSql = '';
if (!empty($limit) || !empty($pageItem)) {
$limitSql = 'LIMIT ';
if (!empty($pageItem)) {
list($pageNo, $rowsPerPage) = $pageItem;
$pageNo = (int) $pageNo;
if ($pageNo < 1) {
throw new \InvalidArgumentException("Invalid pagination page number \"{$pageNo}\"");
}
$rowsPerPage = (int) $rowsPerPage;
// Offset example: "10" skips the first 10 rows, start showing the 11th
$offset = ($pageNo - 1) * $rowsPerPage;
$limitSql .= sprintf('%d, %d', $offset, $rowsPerPage);
} else {
$limitSql .= (int) $limit;
}
}
return $limitSql;
} | [
"protected",
"function",
"getLimitSql",
"(",
"$",
"limit",
",",
"array",
"$",
"pageItem",
"=",
"[",
"]",
")",
"{",
"$",
"limitSql",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"limit",
")",
"||",
"!",
"empty",
"(",
"$",
"pageItem",
")",
")... | Helper method to get LIMIT SQL and paging flag from limit parameter.
@param int $limit A limit number (like 5)
@param array $pageItem A pagination array like [1, 10], where 1 is the page number and 10 the number of
rows per page (first page is 1).
@return string | [
"Helper",
"method",
"to",
"get",
"LIMIT",
"SQL",
"and",
"paging",
"flag",
"from",
"limit",
"parameter",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntityFetcher.php#L50-L73 | train |
starweb/starlit-db | src/AbstractDbEntityFetcher.php | AbstractDbEntityFetcher.getFetchPaginationResult | protected function getFetchPaginationResult(array $objects, $pagination)
{
if ($pagination) {
$totalRowCount = $this->db->fetchValue('SELECT FOUND_ROWS()');
return [$objects, $totalRowCount];
} else {
return $objects;
}
} | php | protected function getFetchPaginationResult(array $objects, $pagination)
{
if ($pagination) {
$totalRowCount = $this->db->fetchValue('SELECT FOUND_ROWS()');
return [$objects, $totalRowCount];
} else {
return $objects;
}
} | [
"protected",
"function",
"getFetchPaginationResult",
"(",
"array",
"$",
"objects",
",",
"$",
"pagination",
")",
"{",
"if",
"(",
"$",
"pagination",
")",
"{",
"$",
"totalRowCount",
"=",
"$",
"this",
"->",
"db",
"->",
"fetchValue",
"(",
"'SELECT FOUND_ROWS()'",
... | Helper method to get pagination result array if pagination is requested.
@param array $objects
@param bool $pagination
@return array | [
"Helper",
"method",
"to",
"get",
"pagination",
"result",
"array",
"if",
"pagination",
"is",
"requested",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntityFetcher.php#L82-L91 | train |
starweb/starlit-db | src/AbstractDbEntityFetcher.php | AbstractDbEntityFetcher.getDbEntitiesFromRowsPaginated | protected function getDbEntitiesFromRowsPaginated(array $rows, $pagination)
{
if ($pagination) {
$totalRowCount = $this->db->fetchValue('SELECT FOUND_ROWS()');
return [$this->getDbEntitiesFromRows($rows), $totalRowCount];
}
return $this->getDbEntitiesFromRows($rows);
} | php | protected function getDbEntitiesFromRowsPaginated(array $rows, $pagination)
{
if ($pagination) {
$totalRowCount = $this->db->fetchValue('SELECT FOUND_ROWS()');
return [$this->getDbEntitiesFromRows($rows), $totalRowCount];
}
return $this->getDbEntitiesFromRows($rows);
} | [
"protected",
"function",
"getDbEntitiesFromRowsPaginated",
"(",
"array",
"$",
"rows",
",",
"$",
"pagination",
")",
"{",
"if",
"(",
"$",
"pagination",
")",
"{",
"$",
"totalRowCount",
"=",
"$",
"this",
"->",
"db",
"->",
"fetchValue",
"(",
"'SELECT FOUND_ROWS()'"... | Helper method to get pagination result as objects if pagination is requested.
@param array $rows
@param bool $pagination
@return array | [
"Helper",
"method",
"to",
"get",
"pagination",
"result",
"as",
"objects",
"if",
"pagination",
"is",
"requested",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntityFetcher.php#L100-L108 | train |
gdbots/ncr-php | src/Search/Elastica/IndexManager.php | IndexManager.createIndex | final public function createIndex(Client $client, SchemaQName $qname, array $context = []): Index
{
static $created = [];
$indexName = $this->getIndexName($qname, $context);
if (isset($created[$indexName])) {
return $created[$indexName];
}
$index = $created[$indexName] = $client->getIndex($indexName);
$type = $this->types[$qname->toString()] ?? $this->types['default'];
$mapper = $this->getNodeMapper($qname);
$settings = $this->filterIndexSettings($this->indexes[$type['index_name'] ?? 'default'], $qname, $context);
unset($settings['fq_index_name']);
try {
if (!$index->exists()) {
$settings['analysis'] = [
'analyzer' => $mapper->getCustomAnalyzers(),
'normalizer' => $mapper->getCustomNormalizers(),
];
$index->create($settings);
}
} catch (\Throwable $e) {
throw new SearchOperationFailed(
sprintf(
'%s while creating index [%s] for qname [%s].',
ClassUtils::getShortName($e),
$index->getName(),
$qname
),
Code::INTERNAL,
$e
);
}
return $index;
} | php | final public function createIndex(Client $client, SchemaQName $qname, array $context = []): Index
{
static $created = [];
$indexName = $this->getIndexName($qname, $context);
if (isset($created[$indexName])) {
return $created[$indexName];
}
$index = $created[$indexName] = $client->getIndex($indexName);
$type = $this->types[$qname->toString()] ?? $this->types['default'];
$mapper = $this->getNodeMapper($qname);
$settings = $this->filterIndexSettings($this->indexes[$type['index_name'] ?? 'default'], $qname, $context);
unset($settings['fq_index_name']);
try {
if (!$index->exists()) {
$settings['analysis'] = [
'analyzer' => $mapper->getCustomAnalyzers(),
'normalizer' => $mapper->getCustomNormalizers(),
];
$index->create($settings);
}
} catch (\Throwable $e) {
throw new SearchOperationFailed(
sprintf(
'%s while creating index [%s] for qname [%s].',
ClassUtils::getShortName($e),
$index->getName(),
$qname
),
Code::INTERNAL,
$e
);
}
return $index;
} | [
"final",
"public",
"function",
"createIndex",
"(",
"Client",
"$",
"client",
",",
"SchemaQName",
"$",
"qname",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"Index",
"{",
"static",
"$",
"created",
"=",
"[",
"]",
";",
"$",
"indexName",
"=",
"$... | Creates the index in ElasticSearch if it doesn't already exist. It will NOT
perform an update as that requires the index be closed and reopened which
is not currently supported on AWS ElasticSearch service.
@param Client $client The Elastica client
@param SchemaQName $qname QName used to derive the index name.
@param array $context Data that helps the NCR Search decide where to read/write data from.
@return Index | [
"Creates",
"the",
"index",
"in",
"ElasticSearch",
"if",
"it",
"doesn",
"t",
"already",
"exist",
".",
"It",
"will",
"NOT",
"perform",
"an",
"update",
"as",
"that",
"requires",
"the",
"index",
"be",
"closed",
"and",
"reopened",
"which",
"is",
"not",
"current... | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Search/Elastica/IndexManager.php#L97-L135 | train |
gdbots/ncr-php | src/Search/Elastica/IndexManager.php | IndexManager.createType | final public function createType(Index $index, SchemaQName $qname): Type
{
$type = new Type($index, $this->getTypeName($qname));
$mapping = $this->getNodeMapper($qname)->getMapping($qname);
$mapping->setType($type);
try {
$mapping->send();
} catch (\Throwable $e) {
throw new SearchOperationFailed(
sprintf(
'%s while putting mapping for type [%s/%s] into ElasticSearch for qname [%s].',
ClassUtils::getShortName($e),
$index->getName(),
$type->getName(),
$qname
),
Code::INTERNAL,
$e
);
}
return $type;
} | php | final public function createType(Index $index, SchemaQName $qname): Type
{
$type = new Type($index, $this->getTypeName($qname));
$mapping = $this->getNodeMapper($qname)->getMapping($qname);
$mapping->setType($type);
try {
$mapping->send();
} catch (\Throwable $e) {
throw new SearchOperationFailed(
sprintf(
'%s while putting mapping for type [%s/%s] into ElasticSearch for qname [%s].',
ClassUtils::getShortName($e),
$index->getName(),
$type->getName(),
$qname
),
Code::INTERNAL,
$e
);
}
return $type;
} | [
"final",
"public",
"function",
"createType",
"(",
"Index",
"$",
"index",
",",
"SchemaQName",
"$",
"qname",
")",
":",
"Type",
"{",
"$",
"type",
"=",
"new",
"Type",
"(",
"$",
"index",
",",
"$",
"this",
"->",
"getTypeName",
"(",
"$",
"qname",
")",
")",
... | Creates or updates the Type in ElasticSearch. This expects the
Index to already exist and have any analyzers it needs.
@param Index $index The Elastica Index to create the Type in.
@param SchemaQName $qname QName used to derive the type name.
@return Type | [
"Creates",
"or",
"updates",
"the",
"Type",
"in",
"ElasticSearch",
".",
"This",
"expects",
"the",
"Index",
"to",
"already",
"exist",
"and",
"have",
"any",
"analyzers",
"it",
"needs",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Search/Elastica/IndexManager.php#L146-L169 | train |
starweb/starlit-db | src/Migration/Migrator.php | Migrator.emptyDb | public function emptyDb()
{
if (($rows = $this->db->fetchRows('SHOW TABLES', [], true))) {
$this->db->exec('SET foreign_key_checks = 0');
foreach ($rows as $row) {
$this->db->exec('DROP TABLE `' . $row[0] . '`');
}
$this->db->exec('SET foreign_key_checks = 1');
}
} | php | public function emptyDb()
{
if (($rows = $this->db->fetchRows('SHOW TABLES', [], true))) {
$this->db->exec('SET foreign_key_checks = 0');
foreach ($rows as $row) {
$this->db->exec('DROP TABLE `' . $row[0] . '`');
}
$this->db->exec('SET foreign_key_checks = 1');
}
} | [
"public",
"function",
"emptyDb",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"rows",
"=",
"$",
"this",
"->",
"db",
"->",
"fetchRows",
"(",
"'SHOW TABLES'",
",",
"[",
"]",
",",
"true",
")",
")",
")",
"{",
"$",
"this",
"->",
"db",
"->",
"exec",
"(",
"'SE... | Empty database. | [
"Empty",
"database",
"."
] | 521efeb4a6ffebf616b02a436575bdc1bf304e88 | https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/Migration/Migrator.php#L286-L295 | train |
gdbots/ncr-php | src/IndexQueryFilterProcessor.php | IndexQueryFilterProcessor.valueMatchesFilter | protected function valueMatchesFilter($value, IndexQueryFilter $filter): bool
{
switch ($filter->getOperator()) {
case IndexQueryFilterOperator::EQUAL_TO:
return $value == $filter->getValue();
case IndexQueryFilterOperator::NOT_EQUAL_TO:
return $value != $filter->getValue();
case IndexQueryFilterOperator::GREATER_THAN:
return $value > $filter->getValue();
case IndexQueryFilterOperator::GREATER_THAN_OR_EQUAL_TO:
return $value >= $filter->getValue();
case IndexQueryFilterOperator::LESS_THAN:
return $value < $filter->getValue();
case IndexQueryFilterOperator::LESS_THAN_OR_EQUAL_TO:
return $value <= $filter->getValue();
}
} | php | protected function valueMatchesFilter($value, IndexQueryFilter $filter): bool
{
switch ($filter->getOperator()) {
case IndexQueryFilterOperator::EQUAL_TO:
return $value == $filter->getValue();
case IndexQueryFilterOperator::NOT_EQUAL_TO:
return $value != $filter->getValue();
case IndexQueryFilterOperator::GREATER_THAN:
return $value > $filter->getValue();
case IndexQueryFilterOperator::GREATER_THAN_OR_EQUAL_TO:
return $value >= $filter->getValue();
case IndexQueryFilterOperator::LESS_THAN:
return $value < $filter->getValue();
case IndexQueryFilterOperator::LESS_THAN_OR_EQUAL_TO:
return $value <= $filter->getValue();
}
} | [
"protected",
"function",
"valueMatchesFilter",
"(",
"$",
"value",
",",
"IndexQueryFilter",
"$",
"filter",
")",
":",
"bool",
"{",
"switch",
"(",
"$",
"filter",
"->",
"getOperator",
"(",
")",
")",
"{",
"case",
"IndexQueryFilterOperator",
"::",
"EQUAL_TO",
":",
... | Returns true if the provided value matches the filter.
@param mixed $value
@param IndexQueryFilter $filter
@return bool | [
"Returns",
"true",
"if",
"the",
"provided",
"value",
"matches",
"the",
"filter",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/IndexQueryFilterProcessor.php#L70-L91 | train |
gdbots/ncr-php | src/Repository/Psr6Ncr.php | Psr6Ncr.beforeSaveCacheItem | protected function beforeSaveCacheItem(CacheItemInterface $cacheItem, Node $node): void
{
$cacheItem->expiresAfter(null)->expiresAt(null);
} | php | protected function beforeSaveCacheItem(CacheItemInterface $cacheItem, Node $node): void
{
$cacheItem->expiresAfter(null)->expiresAt(null);
} | [
"protected",
"function",
"beforeSaveCacheItem",
"(",
"CacheItemInterface",
"$",
"cacheItem",
",",
"Node",
"$",
"node",
")",
":",
"void",
"{",
"$",
"cacheItem",
"->",
"expiresAfter",
"(",
"null",
")",
"->",
"expiresAt",
"(",
"null",
")",
";",
"}"
] | Prepares the cache item before it's saved into the cache pool.
By default, all nodes are stored in cache forever, to change this behavior
either set the default ttl on the cache provider, or tweak the expiry on
a per item basis by overriding this method.
@param CacheItemInterface $cacheItem
@param Node $node | [
"Prepares",
"the",
"cache",
"item",
"before",
"it",
"s",
"saved",
"into",
"the",
"cache",
"pool",
".",
"By",
"default",
"all",
"nodes",
"are",
"stored",
"in",
"cache",
"forever",
"to",
"change",
"this",
"behavior",
"either",
"set",
"the",
"default",
"ttl",... | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Repository/Psr6Ncr.php#L307-L310 | train |
gdbots/ncr-php | src/NcrPreloader.php | NcrPreloader.clear | public function clear(?string $namespace = self::DEFAULT_NAMESPACE): void
{
if (null === $namespace) {
$this->nodeRefs = [];
return;
}
unset($this->nodeRefs[$namespace]);
} | php | public function clear(?string $namespace = self::DEFAULT_NAMESPACE): void
{
if (null === $namespace) {
$this->nodeRefs = [];
return;
}
unset($this->nodeRefs[$namespace]);
} | [
"public",
"function",
"clear",
"(",
"?",
"string",
"$",
"namespace",
"=",
"self",
"::",
"DEFAULT_NAMESPACE",
")",
":",
"void",
"{",
"if",
"(",
"null",
"===",
"$",
"namespace",
")",
"{",
"$",
"this",
"->",
"nodeRefs",
"=",
"[",
"]",
";",
"return",
";"... | Clears the preloaded node refs.
@param string $namespace | [
"Clears",
"the",
"preloaded",
"node",
"refs",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/NcrPreloader.php#L209-L217 | train |
gdbots/ncr-php | src/Search/Elastica/ClientManager.php | ClientManager.getClient | final public function getClient(string $cluster = 'default'): Client
{
if (isset($this->clients[$cluster])) {
return $this->clients[$cluster];
}
if (!$this->hasCluster($cluster)) {
throw new \InvalidArgumentException(
sprintf(
'The cluster [%s] is not one of the available clusters [%s].',
$cluster,
implode(',', $this->getAvailableClusters())
)
);
}
$config = $this->clusters[$cluster];
if (isset($config['debug'])) {
$config['log'] = filter_var($config['debug'], FILTER_VALIDATE_BOOLEAN);
unset($config['debug']);
} else {
$config['log'] = false;
}
if (isset($config['round_robin'])) {
$config['roundRobin'] = filter_var($config['round_robin'], FILTER_VALIDATE_BOOLEAN);
unset($config['round_robin']);
}
$config = $this->configureCluster($cluster, $config);
$servers = $config['servers'];
$configuredServers = [];
unset($config['servers']);
foreach ($servers as $server) {
$configuredServers[] = array_merge($config, $server);
}
$config['servers'] = $configuredServers;
return $this->clients[$cluster] = new Client($config, null, $config['log'] ? $this->logger : null);
} | php | final public function getClient(string $cluster = 'default'): Client
{
if (isset($this->clients[$cluster])) {
return $this->clients[$cluster];
}
if (!$this->hasCluster($cluster)) {
throw new \InvalidArgumentException(
sprintf(
'The cluster [%s] is not one of the available clusters [%s].',
$cluster,
implode(',', $this->getAvailableClusters())
)
);
}
$config = $this->clusters[$cluster];
if (isset($config['debug'])) {
$config['log'] = filter_var($config['debug'], FILTER_VALIDATE_BOOLEAN);
unset($config['debug']);
} else {
$config['log'] = false;
}
if (isset($config['round_robin'])) {
$config['roundRobin'] = filter_var($config['round_robin'], FILTER_VALIDATE_BOOLEAN);
unset($config['round_robin']);
}
$config = $this->configureCluster($cluster, $config);
$servers = $config['servers'];
$configuredServers = [];
unset($config['servers']);
foreach ($servers as $server) {
$configuredServers[] = array_merge($config, $server);
}
$config['servers'] = $configuredServers;
return $this->clients[$cluster] = new Client($config, null, $config['log'] ? $this->logger : null);
} | [
"final",
"public",
"function",
"getClient",
"(",
"string",
"$",
"cluster",
"=",
"'default'",
")",
":",
"Client",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"clients",
"[",
"$",
"cluster",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"client... | Gets an elastica client using the config from the provided cluster name.
All calls with the same cluster name will return the same client instance.
@param string $cluster
@return Client | [
"Gets",
"an",
"elastica",
"client",
"using",
"the",
"config",
"from",
"the",
"provided",
"cluster",
"name",
"."
] | b31c1315144f9a5bc6c48463dd77b6c643fdf250 | https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Search/Elastica/ClientManager.php#L63-L105 | train |
agroviva/egroupware-api | src/Api/Categories.php | Categories.ReadAll | public static function ReadAll($app = 'phpgw')
{
$Categories = new Api\Categories(0, $app);
return $Categories->return_array('all', 0, true, '', 'ASC', '', true, null, -1, '', null);
} | php | public static function ReadAll($app = 'phpgw')
{
$Categories = new Api\Categories(0, $app);
return $Categories->return_array('all', 0, true, '', 'ASC', '', true, null, -1, '', null);
} | [
"public",
"static",
"function",
"ReadAll",
"(",
"$",
"app",
"=",
"'phpgw'",
")",
"{",
"$",
"Categories",
"=",
"new",
"Api",
"\\",
"Categories",
"(",
"0",
",",
"$",
"app",
")",
";",
"return",
"$",
"Categories",
"->",
"return_array",
"(",
"'all'",
",",
... | Returns all Categories.
@param string $app [If app given it will read only the categories of the app] | [
"Returns",
"all",
"Categories",
"."
] | 2dd3d94d5e06d9b4485d41af772d4e9188fd1c76 | https://github.com/agroviva/egroupware-api/blob/2dd3d94d5e06d9b4485d41af772d4e9188fd1c76/src/Api/Categories.php#L35-L40 | train |
salted-herring/salted-library | code/Utilities.php | Utilities.nl2p | public static function nl2p($string, $viewer) {
$items = new \ArrayList();
foreach(explode(PHP_EOL, $string) as $item) {
if (trim($item)) {
$items->push(new \ArrayData(array(
'line' => $item
)));
}
}
return $viewer->customise(new \ArrayData(array(
'Paragraphs' => $items
)))->renderWith('Paragraphs');
} | php | public static function nl2p($string, $viewer) {
$items = new \ArrayList();
foreach(explode(PHP_EOL, $string) as $item) {
if (trim($item)) {
$items->push(new \ArrayData(array(
'line' => $item
)));
}
}
return $viewer->customise(new \ArrayData(array(
'Paragraphs' => $items
)))->renderWith('Paragraphs');
} | [
"public",
"static",
"function",
"nl2p",
"(",
"$",
"string",
",",
"$",
"viewer",
")",
"{",
"$",
"items",
"=",
"new",
"\\",
"ArrayList",
"(",
")",
";",
"foreach",
"(",
"explode",
"(",
"PHP_EOL",
",",
"$",
"string",
")",
"as",
"$",
"item",
")",
"{",
... | Take a string with new line feeds & create paragraphs. | [
"Take",
"a",
"string",
"with",
"new",
"line",
"feeds",
"&",
"create",
"paragraphs",
"."
] | bf062feaa6f11da1a5b7010c15d50976c6cbee6b | https://github.com/salted-herring/salted-library/blob/bf062feaa6f11da1a5b7010c15d50976c6cbee6b/code/Utilities.php#L314-L328 | train |
salted-herring/salted-library | code/Utilities.php | Utilities.getValidKey | public static function getValidKey($pattern, $arr) {
$keys = array();
foreach($arr as $key => $value) {
if (preg_match($pattern, $key)){
$keys[] = $key;
}
}
return $keys;
} | php | public static function getValidKey($pattern, $arr) {
$keys = array();
foreach($arr as $key => $value) {
if (preg_match($pattern, $key)){
$keys[] = $key;
}
}
return $keys;
} | [
"public",
"static",
"function",
"getValidKey",
"(",
"$",
"pattern",
",",
"$",
"arr",
")",
"{",
"$",
"keys",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$"... | find the key that matches a specific pattern.
Used primarily with dbo field tags.
e.g. UtilityFunctions::getValidKey('/*Description/', $this->db); | [
"find",
"the",
"key",
"that",
"matches",
"a",
"specific",
"pattern",
".",
"Used",
"primarily",
"with",
"dbo",
"field",
"tags",
"."
] | bf062feaa6f11da1a5b7010c15d50976c6cbee6b | https://github.com/salted-herring/salted-library/blob/bf062feaa6f11da1a5b7010c15d50976c6cbee6b/code/Utilities.php#L336-L345 | train |
salted-herring/salted-library | code/Utilities.php | Utilities.getWordsWithinCharLimit | public static function getWordsWithinCharLimit($sentence, $limit = 150) {
$str = '';
$i = 1;
if(strlen($sentence) < $limit) {
return $sentence;
}
while (strlen($current = self::getWords($sentence, $i++)) < $limit) {
$str = $current;
}
return $str;
} | php | public static function getWordsWithinCharLimit($sentence, $limit = 150) {
$str = '';
$i = 1;
if(strlen($sentence) < $limit) {
return $sentence;
}
while (strlen($current = self::getWords($sentence, $i++)) < $limit) {
$str = $current;
}
return $str;
} | [
"public",
"static",
"function",
"getWordsWithinCharLimit",
"(",
"$",
"sentence",
",",
"$",
"limit",
"=",
"150",
")",
"{",
"$",
"str",
"=",
"''",
";",
"$",
"i",
"=",
"1",
";",
"if",
"(",
"strlen",
"(",
"$",
"sentence",
")",
"<",
"$",
"limit",
")",
... | Get max number of words within a character limit. | [
"Get",
"max",
"number",
"of",
"words",
"within",
"a",
"character",
"limit",
"."
] | bf062feaa6f11da1a5b7010c15d50976c6cbee6b | https://github.com/salted-herring/salted-library/blob/bf062feaa6f11da1a5b7010c15d50976c6cbee6b/code/Utilities.php#L371-L384 | train |
GrafiteInc/FormMaker | src/Services/InputMaker.php | InputMaker.create | public function create($name, $config, $object = null, $class = null, $reformatted = false, $populated = true)
{
$defaultConfig = include __DIR__.'/../../config/form-maker.php';
if (is_null($class)) {
$class = config('form-maker.forms.form-class', 'form-control');
}
$inputConfig = [
'populated' => $populated,
'name' => $this->inputCalibrator->getName($name, $config),
'id' => $this->inputCalibrator->getId($name, $config),
'class' => $this->prepareTheClass($class, $config),
'config' => $config,
'inputTypes' => Config::get('form-maker.inputTypes', $defaultConfig['inputTypes']),
'inputs' => $this->getInput(),
'object' => $object,
'objectValue' => $this->getObjectValue($object, $name),
'placeholder' => $this->inputCalibrator->placeholder($config, $name),
];
$inputConfig = $this->refineConfigs($inputConfig, $reformatted, $name, $config);
return $this->inputStringPreparer($inputConfig);
} | php | public function create($name, $config, $object = null, $class = null, $reformatted = false, $populated = true)
{
$defaultConfig = include __DIR__.'/../../config/form-maker.php';
if (is_null($class)) {
$class = config('form-maker.forms.form-class', 'form-control');
}
$inputConfig = [
'populated' => $populated,
'name' => $this->inputCalibrator->getName($name, $config),
'id' => $this->inputCalibrator->getId($name, $config),
'class' => $this->prepareTheClass($class, $config),
'config' => $config,
'inputTypes' => Config::get('form-maker.inputTypes', $defaultConfig['inputTypes']),
'inputs' => $this->getInput(),
'object' => $object,
'objectValue' => $this->getObjectValue($object, $name),
'placeholder' => $this->inputCalibrator->placeholder($config, $name),
];
$inputConfig = $this->refineConfigs($inputConfig, $reformatted, $name, $config);
return $this->inputStringPreparer($inputConfig);
} | [
"public",
"function",
"create",
"(",
"$",
"name",
",",
"$",
"config",
",",
"$",
"object",
"=",
"null",
",",
"$",
"class",
"=",
"null",
",",
"$",
"reformatted",
"=",
"false",
",",
"$",
"populated",
"=",
"true",
")",
"{",
"$",
"defaultConfig",
"=",
"... | Create the input HTML.
@param string $name Column/ Input name
@param array $config Array of config info for the input
@param object|array $object Object or Table Object
@param string $class CSS class
@param bool $reformatted Clean the labels and placeholder values
@param bool $populated Set the value of the input to the object's value
@return string | [
"Create",
"the",
"input",
"HTML",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputMaker.php#L72-L96 | train |
GrafiteInc/FormMaker | src/Services/InputMaker.php | InputMaker.getObjectValue | public function getObjectValue($object, $name)
{
if (is_object($object) && isset($object->$name) && !method_exists($object, $name)) {
return $object->$name;
}
// If its a nested value like meta[user[phone]]
if (strpos($name, '[') > 0) {
$nested = explode('[', str_replace(']', '', $name));
$final = $object;
foreach ($nested as $property) {
if (!empty($property) && isset($final->{$property})) {
$final = $final->{$property};
} elseif (is_object($final) && is_null($final->{$property})) {
$final = '';
}
}
return $final;
}
return '';
} | php | public function getObjectValue($object, $name)
{
if (is_object($object) && isset($object->$name) && !method_exists($object, $name)) {
return $object->$name;
}
// If its a nested value like meta[user[phone]]
if (strpos($name, '[') > 0) {
$nested = explode('[', str_replace(']', '', $name));
$final = $object;
foreach ($nested as $property) {
if (!empty($property) && isset($final->{$property})) {
$final = $final->{$property};
} elseif (is_object($final) && is_null($final->{$property})) {
$final = '';
}
}
return $final;
}
return '';
} | [
"public",
"function",
"getObjectValue",
"(",
"$",
"object",
",",
"$",
"name",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"object",
")",
"&&",
"isset",
"(",
"$",
"object",
"->",
"$",
"name",
")",
"&&",
"!",
"method_exists",
"(",
"$",
"object",
",",
... | Get the object value from the object with the name.
@param mixed $object
@param string $name
@return mixed | [
"Get",
"the",
"object",
"value",
"from",
"the",
"object",
"with",
"the",
"name",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputMaker.php#L106-L128 | train |
GrafiteInc/FormMaker | src/Services/InputMaker.php | InputMaker.inputStringPreparer | public function inputStringPreparer($config)
{
$inputString = '';
$beforeAfterCondition = ($this->before($config) > '' || $this->after($config) > '');
$method = $this->getGeneratorMethod($config['inputType']);
if ($beforeAfterCondition) {
$inputString .= '<div class="'.config('form-maker.form.before_after_input_wrapper', 'input-group').'">';
}
$inputString .= $this->before($config);
$inputString .= $this->inputStringGenerator($config);
$inputString .= $this->after($config);
if ($beforeAfterCondition) {
$inputString .= '</div>';
}
if (config('form-maker.form.orientation') == 'horizontal' && !in_array($method, $this->selectedMethods)) {
return '<div class="'.config('form-maker.form.input-column', '').'">'.$inputString.'</div>';
}
return $inputString;
} | php | public function inputStringPreparer($config)
{
$inputString = '';
$beforeAfterCondition = ($this->before($config) > '' || $this->after($config) > '');
$method = $this->getGeneratorMethod($config['inputType']);
if ($beforeAfterCondition) {
$inputString .= '<div class="'.config('form-maker.form.before_after_input_wrapper', 'input-group').'">';
}
$inputString .= $this->before($config);
$inputString .= $this->inputStringGenerator($config);
$inputString .= $this->after($config);
if ($beforeAfterCondition) {
$inputString .= '</div>';
}
if (config('form-maker.form.orientation') == 'horizontal' && !in_array($method, $this->selectedMethods)) {
return '<div class="'.config('form-maker.form.input-column', '').'">'.$inputString.'</div>';
}
return $inputString;
} | [
"public",
"function",
"inputStringPreparer",
"(",
"$",
"config",
")",
"{",
"$",
"inputString",
"=",
"''",
";",
"$",
"beforeAfterCondition",
"=",
"(",
"$",
"this",
"->",
"before",
"(",
"$",
"config",
")",
">",
"''",
"||",
"$",
"this",
"->",
"after",
"("... | Input string preparer.
@param array $config
@return string | [
"Input",
"string",
"preparer",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputMaker.php#L137-L160 | train |
GrafiteInc/FormMaker | src/Services/InputMaker.php | InputMaker.label | public function label($name, $attributes = [])
{
$attributeString = '';
if (!isset($attributes['for'])) {
$attributeString = 'for="'.$name.'"';
}
foreach ($attributes as $key => $value) {
$attributeString .= $key.'="'.$value.'" ';
}
return '<label '.$attributeString.'>'.$name.'</label>';
} | php | public function label($name, $attributes = [])
{
$attributeString = '';
if (!isset($attributes['for'])) {
$attributeString = 'for="'.$name.'"';
}
foreach ($attributes as $key => $value) {
$attributeString .= $key.'="'.$value.'" ';
}
return '<label '.$attributeString.'>'.$name.'</label>';
} | [
"public",
"function",
"label",
"(",
"$",
"name",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"attributeString",
"=",
"''",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'for'",
"]",
")",
")",
"{",
"$",
"attributeString",
"="... | Create a label for an input.
@param string $name
@param array $attributes
@return string | [
"Create",
"a",
"label",
"for",
"an",
"input",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputMaker.php#L170-L183 | train |
GrafiteInc/FormMaker | src/Services/InputMaker.php | InputMaker.refineConfigs | private function refineConfigs($inputConfig, $reformatted, $name, $config)
{
// If validation inputs are available lets prepopulate the fields!
if (!empty($inputConfig['inputs']) && isset($inputConfig['inputs'][$name])) {
$inputConfig['populated'] = true;
$inputConfig['objectValue'] = $inputConfig['inputs'][$name];
} elseif (isset($inputConfig['config']['default_value'])) {
$inputConfig['objectValue'] = $inputConfig['config']['default_value'];
}
if ($reformatted) {
$inputConfig['placeholder'] = $this->inputCalibrator->cleanString($this->inputCalibrator->placeholder($config, $name));
}
if (!isset($config['type'])) {
if (is_array($config)) {
$inputConfig['inputType'] = 'string';
} else {
$inputConfig['inputType'] = $config;
}
} else {
$inputConfig['inputType'] = $config['type'];
}
return $inputConfig;
} | php | private function refineConfigs($inputConfig, $reformatted, $name, $config)
{
// If validation inputs are available lets prepopulate the fields!
if (!empty($inputConfig['inputs']) && isset($inputConfig['inputs'][$name])) {
$inputConfig['populated'] = true;
$inputConfig['objectValue'] = $inputConfig['inputs'][$name];
} elseif (isset($inputConfig['config']['default_value'])) {
$inputConfig['objectValue'] = $inputConfig['config']['default_value'];
}
if ($reformatted) {
$inputConfig['placeholder'] = $this->inputCalibrator->cleanString($this->inputCalibrator->placeholder($config, $name));
}
if (!isset($config['type'])) {
if (is_array($config)) {
$inputConfig['inputType'] = 'string';
} else {
$inputConfig['inputType'] = $config;
}
} else {
$inputConfig['inputType'] = $config['type'];
}
return $inputConfig;
} | [
"private",
"function",
"refineConfigs",
"(",
"$",
"inputConfig",
",",
"$",
"reformatted",
",",
"$",
"name",
",",
"$",
"config",
")",
"{",
"// If validation inputs are available lets prepopulate the fields!",
"if",
"(",
"!",
"empty",
"(",
"$",
"inputConfig",
"[",
"... | Set the configs.
@param array $config
@param bool $reformatted
@param string $name
@param array $config
@return array | [
"Set",
"the",
"configs",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputMaker.php#L257-L282 | train |
GrafiteInc/FormMaker | src/Services/InputMaker.php | InputMaker.inputStringGenerator | private function inputStringGenerator($config)
{
$config = $this->prepareObjectValue($config);
$population = $this->inputCalibrator->getPopulation($config);
$checkType = $this->inputCalibrator->checkType($config, $this->inputGroups['checkbox']);
$selected = $this->inputCalibrator->isSelected($config, $checkType);
$custom = $this->inputCalibrator->getField($config, 'custom');
$method = $this->getGeneratorMethod($config['inputType']);
if (in_array($method, $this->standardMethods)) {
$inputString = $this->htmlGenerator->$method($config, $population, $custom);
} elseif (in_array($method, $this->selectedMethods)) {
// add extra class
$inputString = $this->htmlGenerator->$method($config, $selected, $custom);
} elseif ($method === 'makeRelationship') {
$inputString = $this->htmlGenerator->makeRelationship(
$config,
$this->inputCalibrator->getField($config, 'label', 'name'),
$this->inputCalibrator->getField($config, 'value', 'id'),
$custom
);
} else {
$config = $this->prepareType($config);
$inputString = $this->htmlGenerator->makeHTMLInputString($config);
}
return $inputString;
} | php | private function inputStringGenerator($config)
{
$config = $this->prepareObjectValue($config);
$population = $this->inputCalibrator->getPopulation($config);
$checkType = $this->inputCalibrator->checkType($config, $this->inputGroups['checkbox']);
$selected = $this->inputCalibrator->isSelected($config, $checkType);
$custom = $this->inputCalibrator->getField($config, 'custom');
$method = $this->getGeneratorMethod($config['inputType']);
if (in_array($method, $this->standardMethods)) {
$inputString = $this->htmlGenerator->$method($config, $population, $custom);
} elseif (in_array($method, $this->selectedMethods)) {
// add extra class
$inputString = $this->htmlGenerator->$method($config, $selected, $custom);
} elseif ($method === 'makeRelationship') {
$inputString = $this->htmlGenerator->makeRelationship(
$config,
$this->inputCalibrator->getField($config, 'label', 'name'),
$this->inputCalibrator->getField($config, 'value', 'id'),
$custom
);
} else {
$config = $this->prepareType($config);
$inputString = $this->htmlGenerator->makeHTMLInputString($config);
}
return $inputString;
} | [
"private",
"function",
"inputStringGenerator",
"(",
"$",
"config",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"prepareObjectValue",
"(",
"$",
"config",
")",
";",
"$",
"population",
"=",
"$",
"this",
"->",
"inputCalibrator",
"->",
"getPopulation",
"(",
... | The input string generator.
@param array $config Config
@return string | [
"The",
"input",
"string",
"generator",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputMaker.php#L291-L319 | train |
GrafiteInc/FormMaker | src/Services/InputMaker.php | InputMaker.prepareType | public function prepareType($config)
{
$config['type'] = $config['inputTypes']['string'];
if (isset($config['inputTypes'][$config['inputType']])) {
$config['type'] = $config['inputTypes'][$config['inputType']];
}
return $config;
} | php | public function prepareType($config)
{
$config['type'] = $config['inputTypes']['string'];
if (isset($config['inputTypes'][$config['inputType']])) {
$config['type'] = $config['inputTypes'][$config['inputType']];
}
return $config;
} | [
"public",
"function",
"prepareType",
"(",
"$",
"config",
")",
"{",
"$",
"config",
"[",
"'type'",
"]",
"=",
"$",
"config",
"[",
"'inputTypes'",
"]",
"[",
"'string'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'inputTypes'",
"]",
"[",
"$",... | prepare the type.
@param array $config
@return array | [
"prepare",
"the",
"type",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputMaker.php#L328-L337 | train |
GrafiteInc/FormMaker | src/Services/InputMaker.php | InputMaker.getGeneratorMethod | public function getGeneratorMethod($type)
{
switch ($type) {
case in_array($type, $this->inputGroups['hidden']):
return 'makeHidden';
case in_array($type, $this->inputGroups['text']):
return 'makeText';
case in_array($type, $this->inputGroups['select']):
return 'makeSelected';
case in_array($type, $this->inputGroups['checkbox']):
return 'makeCheckbox';
case in_array($type, $this->inputGroups['radio']):
return 'makeRadio';
case in_array($type, $this->inputGroups['relationship']):
return 'makeRelationship';
default:
return 'makeHTMLInputString';
}
} | php | public function getGeneratorMethod($type)
{
switch ($type) {
case in_array($type, $this->inputGroups['hidden']):
return 'makeHidden';
case in_array($type, $this->inputGroups['text']):
return 'makeText';
case in_array($type, $this->inputGroups['select']):
return 'makeSelected';
case in_array($type, $this->inputGroups['checkbox']):
return 'makeCheckbox';
case in_array($type, $this->inputGroups['radio']):
return 'makeRadio';
case in_array($type, $this->inputGroups['relationship']):
return 'makeRelationship';
default:
return 'makeHTMLInputString';
}
} | [
"public",
"function",
"getGeneratorMethod",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"in_array",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"inputGroups",
"[",
"'hidden'",
"]",
")",
":",
"return",
"'makeHidden'",
";",
"c... | Get the generator method.
@param string $type
@return string | [
"Get",
"the",
"generator",
"method",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputMaker.php#L362-L386 | train |
GrafiteInc/FormMaker | src/Services/InputCalibrator.php | InputCalibrator.getId | public function getId($name, $config)
{
$inputId = str_replace('[]', '', ucfirst($name));
if (isset($config['id'])) {
$inputId = $config['id'];
}
return $inputId;
} | php | public function getId($name, $config)
{
$inputId = str_replace('[]', '', ucfirst($name));
if (isset($config['id'])) {
$inputId = $config['id'];
}
return $inputId;
} | [
"public",
"function",
"getId",
"(",
"$",
"name",
",",
"$",
"config",
")",
"{",
"$",
"inputId",
"=",
"str_replace",
"(",
"'[]'",
",",
"''",
",",
"ucfirst",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'id'",
"]",
... | Customizable input name
@param string $name
@param array $config
@return string | [
"Customizable",
"input",
"name"
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputCalibrator.php#L68-L77 | train |
GrafiteInc/FormMaker | src/Services/InputCalibrator.php | InputCalibrator.isSelected | public function isSelected($config, $checkType)
{
$selected = false;
if (!is_object($config['objectValue'])) {
$selected = (isset($config['inputs'][$config['name']])
|| isset($config['config']['selected'])
|| $config['objectValue'] === 'on'
|| ($config['objectValue'] == 1 && $checkType == 'checked')
|| is_array(json_decode($config['objectValue']))) ? $checkType : '';
}
return $selected;
} | php | public function isSelected($config, $checkType)
{
$selected = false;
if (!is_object($config['objectValue'])) {
$selected = (isset($config['inputs'][$config['name']])
|| isset($config['config']['selected'])
|| $config['objectValue'] === 'on'
|| ($config['objectValue'] == 1 && $checkType == 'checked')
|| is_array(json_decode($config['objectValue']))) ? $checkType : '';
}
return $selected;
} | [
"public",
"function",
"isSelected",
"(",
"$",
"config",
",",
"$",
"checkType",
")",
"{",
"$",
"selected",
"=",
"false",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"config",
"[",
"'objectValue'",
"]",
")",
")",
"{",
"$",
"selected",
"=",
"(",
"isset"... | Has been selected.
@param array $config
@param string $checkType Type of checkmark
@return bool | [
"Has",
"been",
"selected",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputCalibrator.php#L87-L100 | train |
GrafiteInc/FormMaker | src/Services/InputCalibrator.php | InputCalibrator.placeholder | public function placeholder($field, $column)
{
if (!is_array($field) && !in_array($field, $this->columnTypes)) {
return ucfirst($field);
}
if (strpos($column, '[') > 0) {
$nested = explode('[', str_replace(']', '', $column));
$column = implode(' ', $nested);
}
$alt_name = (isset($field['alt_name'])) ? $field['alt_name'] : ucfirst($column);
$placeholder = (isset($field['placeholder'])) ? $field['placeholder'] : $this->cleanString($alt_name);
return $placeholder;
} | php | public function placeholder($field, $column)
{
if (!is_array($field) && !in_array($field, $this->columnTypes)) {
return ucfirst($field);
}
if (strpos($column, '[') > 0) {
$nested = explode('[', str_replace(']', '', $column));
$column = implode(' ', $nested);
}
$alt_name = (isset($field['alt_name'])) ? $field['alt_name'] : ucfirst($column);
$placeholder = (isset($field['placeholder'])) ? $field['placeholder'] : $this->cleanString($alt_name);
return $placeholder;
} | [
"public",
"function",
"placeholder",
"(",
"$",
"field",
",",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"field",
")",
"&&",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"columnTypes",
")",
")",
"{",
"return",
"ucf... | Create the placeholder.
@param array $field Field from Column Array
@param string $column Column name
@return string | [
"Create",
"the",
"placeholder",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/InputCalibrator.php#L139-L154 | train |
GrafiteInc/FormMaker | src/Services/FormMaker.php | FormMaker.fromTable | public function fromTable(
$table,
$columns = null,
$class = null,
$view = null,
$reformatted = true,
$populated = false,
$idAndTimestamps = false
) {
$formBuild = [];
if (is_null($class)) {
$class = config('form-maker.forms.form-class', 'form-control');
}
$tableColumns = $this->getTableColumns($table, true);
if (is_null($columns)) {
foreach ($tableColumns as $column => $value) {
$columns[$column] = $value['type'];
}
}
if (!$idAndTimestamps) {
unset($columns['id']);
unset($columns['created_at']);
unset($columns['updated_at']);
unset($columns['deleted_at']);
}
foreach ($columns as $column => $columnConfig) {
if (is_numeric($column)) {
$column = $columnConfig;
}
$errors = $this->getFormErrors();
$input = $this->inputMaker->create($column, $columnConfig, $column, $class, $reformatted, $populated);
$formBuild[] = $this->formBuilder($view, $errors, $columnConfig, $column, $input);
}
return $this->buildUsingColumns($formBuild, config('form-maker.form.theme'));
} | php | public function fromTable(
$table,
$columns = null,
$class = null,
$view = null,
$reformatted = true,
$populated = false,
$idAndTimestamps = false
) {
$formBuild = [];
if (is_null($class)) {
$class = config('form-maker.forms.form-class', 'form-control');
}
$tableColumns = $this->getTableColumns($table, true);
if (is_null($columns)) {
foreach ($tableColumns as $column => $value) {
$columns[$column] = $value['type'];
}
}
if (!$idAndTimestamps) {
unset($columns['id']);
unset($columns['created_at']);
unset($columns['updated_at']);
unset($columns['deleted_at']);
}
foreach ($columns as $column => $columnConfig) {
if (is_numeric($column)) {
$column = $columnConfig;
}
$errors = $this->getFormErrors();
$input = $this->inputMaker->create($column, $columnConfig, $column, $class, $reformatted, $populated);
$formBuild[] = $this->formBuilder($view, $errors, $columnConfig, $column, $input);
}
return $this->buildUsingColumns($formBuild, config('form-maker.form.theme'));
} | [
"public",
"function",
"fromTable",
"(",
"$",
"table",
",",
"$",
"columns",
"=",
"null",
",",
"$",
"class",
"=",
"null",
",",
"$",
"view",
"=",
"null",
",",
"$",
"reformatted",
"=",
"true",
",",
"$",
"populated",
"=",
"false",
",",
"$",
"idAndTimestam... | Generate a form from a table.
@param string $table Table name
@param array $columns Array of columns and details regarding them see config/forms.php for examples
@param string $class Class names to be given to the inputs
@param string $view View to use - for custom form layouts
@param bool $reformatted Corrects the table column names to clean words if no columns array provided
@param bool $populated Populates the inputs with the column names as values
@param bool $idAndTimestamps Allows id and Timestamp columns
@return string | [
"Generate",
"a",
"form",
"from",
"a",
"table",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/FormMaker.php#L88-L128 | train |
GrafiteInc/FormMaker | src/Services/FormMaker.php | FormMaker.fromArray | public function fromArray(
$array,
$columns = null,
$view = null,
$class = null,
$populated = true,
$reformatted = false,
$timestamps = false
) {
$formBuild = [];
if (is_null($class)) {
$class = config('form-maker.forms.form-class', 'form-control');
}
$array = $this->cleanupIdAndTimeStamps($array, $timestamps, false);
$errors = $this->getFormErrors();
if (is_null($columns)) {
$columns = $array;
}
foreach ($columns as $column => $columnConfig) {
if (is_numeric($column)) {
$column = $columnConfig;
}
if ($column === 'id') {
$columnConfig = ['type' => 'hidden'];
}
$input = $this->inputMaker->create($column, $columnConfig, $array, $class, $reformatted, $populated);
$formBuild[] = $this->formBuilder($view, $errors, $columnConfig, $column, $input);
}
return $this->buildUsingColumns($formBuild, config('form-maker.form.theme'));
} | php | public function fromArray(
$array,
$columns = null,
$view = null,
$class = null,
$populated = true,
$reformatted = false,
$timestamps = false
) {
$formBuild = [];
if (is_null($class)) {
$class = config('form-maker.forms.form-class', 'form-control');
}
$array = $this->cleanupIdAndTimeStamps($array, $timestamps, false);
$errors = $this->getFormErrors();
if (is_null($columns)) {
$columns = $array;
}
foreach ($columns as $column => $columnConfig) {
if (is_numeric($column)) {
$column = $columnConfig;
}
if ($column === 'id') {
$columnConfig = ['type' => 'hidden'];
}
$input = $this->inputMaker->create($column, $columnConfig, $array, $class, $reformatted, $populated);
$formBuild[] = $this->formBuilder($view, $errors, $columnConfig, $column, $input);
}
return $this->buildUsingColumns($formBuild, config('form-maker.form.theme'));
} | [
"public",
"function",
"fromArray",
"(",
"$",
"array",
",",
"$",
"columns",
"=",
"null",
",",
"$",
"view",
"=",
"null",
",",
"$",
"class",
"=",
"null",
",",
"$",
"populated",
"=",
"true",
",",
"$",
"reformatted",
"=",
"false",
",",
"$",
"timestamps",
... | Build the form from an array.
@param array $array
@param array $columns
@param string $view A template to use for the rows
@param string $class Default input class
@param bool $populated Is content populated
@param bool $reformatted Are column names reformatted
@param bool $timestamps Are the timestamps available?
@return string | [
"Build",
"the",
"form",
"from",
"an",
"array",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/FormMaker.php#L143-L178 | train |
GrafiteInc/FormMaker | src/Services/FormMaker.php | FormMaker.cleanupIdAndTimeStamps | public function cleanupIdAndTimeStamps($collection, $timestamps, $id)
{
if (!$timestamps) {
unset($collection['created_at']);
unset($collection['updated_at']);
}
if (!$id) {
unset($collection['id']);
}
return $collection;
} | php | public function cleanupIdAndTimeStamps($collection, $timestamps, $id)
{
if (!$timestamps) {
unset($collection['created_at']);
unset($collection['updated_at']);
}
if (!$id) {
unset($collection['id']);
}
return $collection;
} | [
"public",
"function",
"cleanupIdAndTimeStamps",
"(",
"$",
"collection",
",",
"$",
"timestamps",
",",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"$",
"timestamps",
")",
"{",
"unset",
"(",
"$",
"collection",
"[",
"'created_at'",
"]",
")",
";",
"unset",
"(",
"$... | Cleanup the ID and TimeStamp columns.
@param array $collection
@param bool $timestamps
@param bool $id
@return array | [
"Cleanup",
"the",
"ID",
"and",
"TimeStamp",
"columns",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/FormMaker.php#L238-L250 | train |
GrafiteInc/FormMaker | src/Services/FormMaker.php | FormMaker.formBuilder | private function formBuilder($view, $errors, $field, $column, $input)
{
$formGroupClass = config('form-maker.form.group-class', 'form-group');
$formErrorClass = config('form-maker.form.error-class', 'has-error');
$errorHighlight = '';
$errorMessage = false;
if (!empty($errors) && $errors->has($column)) {
$errorHighlight = ' '.$formErrorClass;
$errorMessage = $errors->get($column);
}
if (is_null($view)) {
$formBuild = '<div class="'.$formGroupClass.' '.$errorHighlight.'">';
$formBuild .= $this->formContentBuild($field, $column, $input, $errorMessage);
$formBuild .= '</div>';
} else {
$formBuild = View::make($view, [
'labelFor' => ucfirst($column),
'label' => $this->columnLabel($field, $column),
'input' => $input,
'field' => $field,
'errorMessage' => $this->errorMessage($errorMessage),
'errorHighlight' => $errorHighlight,
]);
}
return $formBuild;
} | php | private function formBuilder($view, $errors, $field, $column, $input)
{
$formGroupClass = config('form-maker.form.group-class', 'form-group');
$formErrorClass = config('form-maker.form.error-class', 'has-error');
$errorHighlight = '';
$errorMessage = false;
if (!empty($errors) && $errors->has($column)) {
$errorHighlight = ' '.$formErrorClass;
$errorMessage = $errors->get($column);
}
if (is_null($view)) {
$formBuild = '<div class="'.$formGroupClass.' '.$errorHighlight.'">';
$formBuild .= $this->formContentBuild($field, $column, $input, $errorMessage);
$formBuild .= '</div>';
} else {
$formBuild = View::make($view, [
'labelFor' => ucfirst($column),
'label' => $this->columnLabel($field, $column),
'input' => $input,
'field' => $field,
'errorMessage' => $this->errorMessage($errorMessage),
'errorHighlight' => $errorHighlight,
]);
}
return $formBuild;
} | [
"private",
"function",
"formBuilder",
"(",
"$",
"view",
",",
"$",
"errors",
",",
"$",
"field",
",",
"$",
"column",
",",
"$",
"input",
")",
"{",
"$",
"formGroupClass",
"=",
"config",
"(",
"'form-maker.form.group-class'",
",",
"'form-group'",
")",
";",
"$",
... | Constructs HTML forms.
@param string $view View template
@param array|object $errors
@param array $field Array of field values
@param string $column Column name
@param string $input Input string
@return string | [
"Constructs",
"HTML",
"forms",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/FormMaker.php#L279-L308 | train |
GrafiteInc/FormMaker | src/Services/FormMaker.php | FormMaker.formContentBuild | public function formContentBuild($field, $column, $input, $errorMessage)
{
$labelColumn = $labelCheckableColumn = '';
$singleLineCheckType = false;
$formLabelClass = config('form-maker.form.label-class', 'control-label');
if (config('form-maker.form.orientation') == 'horizontal') {
$labelColumn = config('form-maker.form.label-column');
$labelCheckableColumn = config('form-maker.form.checkbox-column');
$singleLineCheckType = true;
}
$name = ucfirst($this->inputCalibrator->getName($column, $field));
$formBuild = '<label class="'.trim($formLabelClass.' '.$labelColumn).'" for="'.$name.'">';
$formBuild .= $this->inputCalibrator->cleanString($this->columnLabel($field, $column));
$formBuild .= '</label>'.$input.$this->errorMessage($errorMessage);
if (isset($field['type'])) {
if (in_array($field['type'], ['radio', 'checkbox'])) {
$formBuild = '<div class="'.$field['type'].'">';
if ($singleLineCheckType) {
$formBuild .= '<div class="'.$labelCheckableColumn.'">';
}
$formBuild .= '<label for="'.ucfirst($column).'" class="'.$formLabelClass.'">'.$input;
$formBuild .= $this->inputCalibrator->cleanString($this->columnLabel($field, $column));
$formBuild .= '</label>'.$this->errorMessage($errorMessage).'</div>';
if ($singleLineCheckType) {
$formBuild .= '</div>';
}
} elseif (stristr($field['type'], 'hidden')) {
$formBuild = $input;
}
}
return $formBuild;
} | php | public function formContentBuild($field, $column, $input, $errorMessage)
{
$labelColumn = $labelCheckableColumn = '';
$singleLineCheckType = false;
$formLabelClass = config('form-maker.form.label-class', 'control-label');
if (config('form-maker.form.orientation') == 'horizontal') {
$labelColumn = config('form-maker.form.label-column');
$labelCheckableColumn = config('form-maker.form.checkbox-column');
$singleLineCheckType = true;
}
$name = ucfirst($this->inputCalibrator->getName($column, $field));
$formBuild = '<label class="'.trim($formLabelClass.' '.$labelColumn).'" for="'.$name.'">';
$formBuild .= $this->inputCalibrator->cleanString($this->columnLabel($field, $column));
$formBuild .= '</label>'.$input.$this->errorMessage($errorMessage);
if (isset($field['type'])) {
if (in_array($field['type'], ['radio', 'checkbox'])) {
$formBuild = '<div class="'.$field['type'].'">';
if ($singleLineCheckType) {
$formBuild .= '<div class="'.$labelCheckableColumn.'">';
}
$formBuild .= '<label for="'.ucfirst($column).'" class="'.$formLabelClass.'">'.$input;
$formBuild .= $this->inputCalibrator->cleanString($this->columnLabel($field, $column));
$formBuild .= '</label>'.$this->errorMessage($errorMessage).'</div>';
if ($singleLineCheckType) {
$formBuild .= '</div>';
}
} elseif (stristr($field['type'], 'hidden')) {
$formBuild = $input;
}
}
return $formBuild;
} | [
"public",
"function",
"formContentBuild",
"(",
"$",
"field",
",",
"$",
"column",
",",
"$",
"input",
",",
"$",
"errorMessage",
")",
"{",
"$",
"labelColumn",
"=",
"$",
"labelCheckableColumn",
"=",
"''",
";",
"$",
"singleLineCheckType",
"=",
"false",
";",
"$"... | Form Content Builder.
@param array $field Array of field values
@param string $column Column name
@param string $input Input string
@param string $errorMessage
@return string | [
"Form",
"Content",
"Builder",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/FormMaker.php#L320-L356 | train |
GrafiteInc/FormMaker | src/Services/FormMaker.php | FormMaker.buildBootstrapColumnForm | private function buildBootstrapColumnForm($formBuild, $columns)
{
$newFormBuild = [];
$formChunks = array_chunk($formBuild, $columns);
$class = 'col-md-'.(12 / $columns);
foreach ($formChunks as $chunk) {
$newFormBuild[] = '<div class="row">';
foreach ($chunk as $element) {
$newFormBuild[] = '<div class="'.$class.'">';
$newFormBuild[] = $element;
$newFormBuild[] = '</div>';
}
$newFormBuild[] = '</div>';
}
return implode("", $newFormBuild);
} | php | private function buildBootstrapColumnForm($formBuild, $columns)
{
$newFormBuild = [];
$formChunks = array_chunk($formBuild, $columns);
$class = 'col-md-'.(12 / $columns);
foreach ($formChunks as $chunk) {
$newFormBuild[] = '<div class="row">';
foreach ($chunk as $element) {
$newFormBuild[] = '<div class="'.$class.'">';
$newFormBuild[] = $element;
$newFormBuild[] = '</div>';
}
$newFormBuild[] = '</div>';
}
return implode("", $newFormBuild);
} | [
"private",
"function",
"buildBootstrapColumnForm",
"(",
"$",
"formBuild",
",",
"$",
"columns",
")",
"{",
"$",
"newFormBuild",
"=",
"[",
"]",
";",
"$",
"formChunks",
"=",
"array_chunk",
"(",
"$",
"formBuild",
",",
"$",
"columns",
")",
";",
"$",
"class",
"... | Build a two column form using standard bootstrap classes
@param array $formBuild
@return string | [
"Build",
"a",
"two",
"column",
"form",
"using",
"standard",
"bootstrap",
"classes"
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/FormMaker.php#L400-L417 | train |
GrafiteInc/FormMaker | src/Services/FormMaker.php | FormMaker.columnLabel | private function columnLabel($field, $column)
{
if (!is_array($field) && !in_array($field, $this->columnTypes)) {
return ucfirst($field);
}
return (isset($field['alt_name'])) ? $field['alt_name'] : ucfirst($column);
} | php | private function columnLabel($field, $column)
{
if (!is_array($field) && !in_array($field, $this->columnTypes)) {
return ucfirst($field);
}
return (isset($field['alt_name'])) ? $field['alt_name'] : ucfirst($column);
} | [
"private",
"function",
"columnLabel",
"(",
"$",
"field",
",",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"field",
")",
"&&",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"columnTypes",
")",
")",
"{",
"return",
"uc... | Create the column label.
@param array $field Field from Column Array
@param string $column Column name
@return string | [
"Create",
"the",
"column",
"label",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Services/FormMaker.php#L445-L452 | train |
GrafiteInc/FormMaker | src/Generators/HtmlGenerator.php | HtmlGenerator.makeHidden | public function makeHidden($config, $population, $custom)
{
return '<input '.$this->processCustom($custom).' id="'.$this->getId($config).'" name="'.$config['name'].'" type="hidden" value="'.$population.'">';
} | php | public function makeHidden($config, $population, $custom)
{
return '<input '.$this->processCustom($custom).' id="'.$this->getId($config).'" name="'.$config['name'].'" type="hidden" value="'.$population.'">';
} | [
"public",
"function",
"makeHidden",
"(",
"$",
"config",
",",
"$",
"population",
",",
"$",
"custom",
")",
"{",
"return",
"'<input '",
".",
"$",
"this",
"->",
"processCustom",
"(",
"$",
"custom",
")",
".",
"' id=\"'",
".",
"$",
"this",
"->",
"getId",
"("... | Make a hidden input.
@param array $config
@param string $population
@param mixed $custom
@return string | [
"Make",
"a",
"hidden",
"input",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Generators/HtmlGenerator.php#L27-L30 | train |
GrafiteInc/FormMaker | src/Generators/HtmlGenerator.php | HtmlGenerator.makeText | public function makeText($config, $population, $custom)
{
return '<textarea '.$this->processCustom($custom).' id="'.$this->getId($config).'" class="'.$config['class'].'" name="'.$config['name'].'" placeholder="'.$config['placeholder'].'">'.$population.'</textarea>';
} | php | public function makeText($config, $population, $custom)
{
return '<textarea '.$this->processCustom($custom).' id="'.$this->getId($config).'" class="'.$config['class'].'" name="'.$config['name'].'" placeholder="'.$config['placeholder'].'">'.$population.'</textarea>';
} | [
"public",
"function",
"makeText",
"(",
"$",
"config",
",",
"$",
"population",
",",
"$",
"custom",
")",
"{",
"return",
"'<textarea '",
".",
"$",
"this",
"->",
"processCustom",
"(",
"$",
"custom",
")",
".",
"' id=\"'",
".",
"$",
"this",
"->",
"getId",
"(... | Make text input.
@param array $config
@param string $population
@param mixed $custom
@return string | [
"Make",
"text",
"input",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Generators/HtmlGenerator.php#L41-L44 | train |
GrafiteInc/FormMaker | src/Generators/HtmlGenerator.php | HtmlGenerator.makeSelected | public function makeSelected($config, $selected, $custom)
{
$options = $prefix = $suffix = '';
if (isset($config['config']['multiple'])) {
$custom = 'multiple';
$config['name'] = $config['name'].'[]';
}
if (config('form-maker.form.orientation') === 'horizontal') {
$prefix = '<div class="'.config('form-maker.form.input-column').'">';
$suffix = '</div>';
}
foreach ($config['config']['options'] as $key => $value) {
$selectedValue = '';
if (isset($config['config']['multiple']) && is_object($selected)) {
if (in_array($value, $selected->toArray())) {
$selectedValue = 'selected';
}
} else {
if ($selected == '') {
$selectedValue = ((string) $config['objectValue'] === (string) $value) ? 'selected' : '';
} else {
if (isset($config['objectValue']) && is_array(json_decode($config['objectValue']))) {
$selectedValue = (in_array($value, json_decode($config['objectValue']))) ? 'selected' : '';
} else {
$selectedValue = ((string) $selected === (string) $value) ? 'selected' : '';
}
}
}
$options .= '<option value="'.$value.'" '.$selectedValue.'>'.$key.'</option>';
}
return $prefix.'<select '.$this->processCustom($custom).' id="'.$this->getId($config).'" class="'.$config['class'].'" name="'.$config['name'].'">'.$options.'</select>'.$suffix;
} | php | public function makeSelected($config, $selected, $custom)
{
$options = $prefix = $suffix = '';
if (isset($config['config']['multiple'])) {
$custom = 'multiple';
$config['name'] = $config['name'].'[]';
}
if (config('form-maker.form.orientation') === 'horizontal') {
$prefix = '<div class="'.config('form-maker.form.input-column').'">';
$suffix = '</div>';
}
foreach ($config['config']['options'] as $key => $value) {
$selectedValue = '';
if (isset($config['config']['multiple']) && is_object($selected)) {
if (in_array($value, $selected->toArray())) {
$selectedValue = 'selected';
}
} else {
if ($selected == '') {
$selectedValue = ((string) $config['objectValue'] === (string) $value) ? 'selected' : '';
} else {
if (isset($config['objectValue']) && is_array(json_decode($config['objectValue']))) {
$selectedValue = (in_array($value, json_decode($config['objectValue']))) ? 'selected' : '';
} else {
$selectedValue = ((string) $selected === (string) $value) ? 'selected' : '';
}
}
}
$options .= '<option value="'.$value.'" '.$selectedValue.'>'.$key.'</option>';
}
return $prefix.'<select '.$this->processCustom($custom).' id="'.$this->getId($config).'" class="'.$config['class'].'" name="'.$config['name'].'">'.$options.'</select>'.$suffix;
} | [
"public",
"function",
"makeSelected",
"(",
"$",
"config",
",",
"$",
"selected",
",",
"$",
"custom",
")",
"{",
"$",
"options",
"=",
"$",
"prefix",
"=",
"$",
"suffix",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'config'",
"]",
"[",... | Make a select input.
@param array $config
@param string $selected
@param mixed $custom
@return string | [
"Make",
"a",
"select",
"input",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Generators/HtmlGenerator.php#L55-L92 | train |
GrafiteInc/FormMaker | src/Generators/HtmlGenerator.php | HtmlGenerator.makeCheckbox | public function makeCheckbox($config, $selected, $custom)
{
if (str_contains($config['class'], 'form-control')) {
if (str_contains($config['class'], 'form-check-inline')) {
$config['class'] = str_replace('form-control', '', $config['class']);
} else {
$config['class'] = str_replace('form-control', 'form-check-input', $config['class']);
}
}
return '<input '.$this->processCustom($custom).' id="'.$this->getId($config).'" '.$selected.' type="checkbox" name="'.$config['name'].'" class="'. $config['class'] .'">';
} | php | public function makeCheckbox($config, $selected, $custom)
{
if (str_contains($config['class'], 'form-control')) {
if (str_contains($config['class'], 'form-check-inline')) {
$config['class'] = str_replace('form-control', '', $config['class']);
} else {
$config['class'] = str_replace('form-control', 'form-check-input', $config['class']);
}
}
return '<input '.$this->processCustom($custom).' id="'.$this->getId($config).'" '.$selected.' type="checkbox" name="'.$config['name'].'" class="'. $config['class'] .'">';
} | [
"public",
"function",
"makeCheckbox",
"(",
"$",
"config",
",",
"$",
"selected",
",",
"$",
"custom",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"config",
"[",
"'class'",
"]",
",",
"'form-control'",
")",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",... | Make a checkbox.
@param array $config
@param string $selected
@param mixed $custom
@return string | [
"Make",
"a",
"checkbox",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Generators/HtmlGenerator.php#L103-L114 | train |
GrafiteInc/FormMaker | src/Generators/HtmlGenerator.php | HtmlGenerator.makeRadio | public function makeRadio($config, $selected, $custom)
{
return '<input '.$this->processCustom($custom).' id="'.$this->getId($config).'" '.$selected.' type="radio" name="'.$config['name'].'" class="'. $config['class'] .'">';
} | php | public function makeRadio($config, $selected, $custom)
{
return '<input '.$this->processCustom($custom).' id="'.$this->getId($config).'" '.$selected.' type="radio" name="'.$config['name'].'" class="'. $config['class'] .'">';
} | [
"public",
"function",
"makeRadio",
"(",
"$",
"config",
",",
"$",
"selected",
",",
"$",
"custom",
")",
"{",
"return",
"'<input '",
".",
"$",
"this",
"->",
"processCustom",
"(",
"$",
"custom",
")",
".",
"' id=\"'",
".",
"$",
"this",
"->",
"getId",
"(",
... | Make a radio input.
@param array $config
@param string $selected
@param mixed $custom
@return string | [
"Make",
"a",
"radio",
"input",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Generators/HtmlGenerator.php#L125-L128 | train |
GrafiteInc/FormMaker | src/Generators/HtmlGenerator.php | HtmlGenerator.makeRelationship | public function makeRelationship($config, $label = 'name', $value = 'id', $custom = '')
{
$object = $config['object'];
if (isset($config['config']['relationship'])) {
$relationship = $config['config']['relationship'];
} else {
$relationship = $config['name'];
}
// Removes the array indication for select multiple
$relationship = str_replace('[]', '', $relationship);
$method = 'all';
if (!is_object($config['config']['model'])) {
$class = app()->make($config['config']['model']);
} else {
$class = $config['config']['model'];
}
if (isset($config['config']['method'])) {
$method = $config['config']['method'];
}
if (isset($config['config']['params'])) {
$items = $class->$method($config['config']['params']);
} else {
$items = $class->$method();
}
if (isset($config['config']['nullable']) && $config['config']['nullable'] === true) {
$config['config']['options']['- Select -'] = null;
}
foreach ($items as $item) {
$config['config']['options'][$item->$label] = $item->$value;
}
if (!isset($config['config']['selected'])) {
if (!isset($config['config']['multiple'])) {
$selected = '';
if (is_object($object) && method_exists($object, $relationship)) {
if ($object->$relationship()->first()) {
$selected = $object->$relationship()->first()->$value;
}
}
$relationship = str_replace('_id', '', $relationship);
if (method_exists($object, $relationship)) {
if ($object->$relationship()->first()) {
$selected = $object->$relationship()->first()->$value;
}
}
} else {
$selected = $class->$method()->pluck($value, $label);
}
} else {
$selected = $config['config']['selected'];
}
return $this->makeSelected($config, $selected, $custom);
} | php | public function makeRelationship($config, $label = 'name', $value = 'id', $custom = '')
{
$object = $config['object'];
if (isset($config['config']['relationship'])) {
$relationship = $config['config']['relationship'];
} else {
$relationship = $config['name'];
}
// Removes the array indication for select multiple
$relationship = str_replace('[]', '', $relationship);
$method = 'all';
if (!is_object($config['config']['model'])) {
$class = app()->make($config['config']['model']);
} else {
$class = $config['config']['model'];
}
if (isset($config['config']['method'])) {
$method = $config['config']['method'];
}
if (isset($config['config']['params'])) {
$items = $class->$method($config['config']['params']);
} else {
$items = $class->$method();
}
if (isset($config['config']['nullable']) && $config['config']['nullable'] === true) {
$config['config']['options']['- Select -'] = null;
}
foreach ($items as $item) {
$config['config']['options'][$item->$label] = $item->$value;
}
if (!isset($config['config']['selected'])) {
if (!isset($config['config']['multiple'])) {
$selected = '';
if (is_object($object) && method_exists($object, $relationship)) {
if ($object->$relationship()->first()) {
$selected = $object->$relationship()->first()->$value;
}
}
$relationship = str_replace('_id', '', $relationship);
if (method_exists($object, $relationship)) {
if ($object->$relationship()->first()) {
$selected = $object->$relationship()->first()->$value;
}
}
} else {
$selected = $class->$method()->pluck($value, $label);
}
} else {
$selected = $config['config']['selected'];
}
return $this->makeSelected($config, $selected, $custom);
} | [
"public",
"function",
"makeRelationship",
"(",
"$",
"config",
",",
"$",
"label",
"=",
"'name'",
",",
"$",
"value",
"=",
"'id'",
",",
"$",
"custom",
"=",
"''",
")",
"{",
"$",
"object",
"=",
"$",
"config",
"[",
"'object'",
"]",
";",
"if",
"(",
"isset... | Make a relationship input.
@param array $config
@param string $label
@param string $value
@param mixed $custom
@return string | [
"Make",
"a",
"relationship",
"input",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Generators/HtmlGenerator.php#L146-L209 | train |
GrafiteInc/FormMaker | src/Generators/HtmlGenerator.php | HtmlGenerator.makeHTMLInputString | public function makeHTMLInputString($config)
{
$custom = $this->getCustom($config);
$multiple = $this->isMultiple($config, 'multiple');
$multipleArray = $this->isMultiple($config, '[]');
$floatingNumber = $this->getFloatingNumber($config);
$population = $this->getPopulation($config);
if (is_array($config['objectValue']) && $config['type'] === 'file') {
$population = '';
}
$inputString = '<input '.$this->processCustom($custom).' id="'.$this->getId($config).'" class="'.$config['class'].'" type="'.$config['type'].'" name="'.$config['name'].$multipleArray.'" '.$floatingNumber.' '.$multiple.' '.$population.' placeholder="'.$config['placeholder'].'">';
return $inputString;
} | php | public function makeHTMLInputString($config)
{
$custom = $this->getCustom($config);
$multiple = $this->isMultiple($config, 'multiple');
$multipleArray = $this->isMultiple($config, '[]');
$floatingNumber = $this->getFloatingNumber($config);
$population = $this->getPopulation($config);
if (is_array($config['objectValue']) && $config['type'] === 'file') {
$population = '';
}
$inputString = '<input '.$this->processCustom($custom).' id="'.$this->getId($config).'" class="'.$config['class'].'" type="'.$config['type'].'" name="'.$config['name'].$multipleArray.'" '.$floatingNumber.' '.$multiple.' '.$population.' placeholder="'.$config['placeholder'].'">';
return $inputString;
} | [
"public",
"function",
"makeHTMLInputString",
"(",
"$",
"config",
")",
"{",
"$",
"custom",
"=",
"$",
"this",
"->",
"getCustom",
"(",
"$",
"config",
")",
";",
"$",
"multiple",
"=",
"$",
"this",
"->",
"isMultiple",
"(",
"$",
"config",
",",
"'multiple'",
"... | Generate a standard HTML input string.
@param array $config Config array
@return string | [
"Generate",
"a",
"standard",
"HTML",
"input",
"string",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Generators/HtmlGenerator.php#L218-L233 | train |
GrafiteInc/FormMaker | src/Generators/HtmlGenerator.php | HtmlGenerator.getPopulation | public function getPopulation($config)
{
if ($config['populated'] && ($config['name'] !== $config['objectValue'])) {
if ($config['type'] == 'date' && method_exists($config['objectValue'], 'format')) {
$format = (isset($config['format'])) ? $config['format'] : 'Y-m-d';
$config['objectValue'] = $config['objectValue']->format($format);
}
return 'value="'.htmlspecialchars($config['objectValue']).'"';
}
return '';
} | php | public function getPopulation($config)
{
if ($config['populated'] && ($config['name'] !== $config['objectValue'])) {
if ($config['type'] == 'date' && method_exists($config['objectValue'], 'format')) {
$format = (isset($config['format'])) ? $config['format'] : 'Y-m-d';
$config['objectValue'] = $config['objectValue']->format($format);
}
return 'value="'.htmlspecialchars($config['objectValue']).'"';
}
return '';
} | [
"public",
"function",
"getPopulation",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"[",
"'populated'",
"]",
"&&",
"(",
"$",
"config",
"[",
"'name'",
"]",
"!==",
"$",
"config",
"[",
"'objectValue'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"c... | Get the population.
@param array $config
@return string | [
"Get",
"the",
"population",
"."
] | 9c92d5592e852183c30b20193970bfc1afef2596 | https://github.com/GrafiteInc/FormMaker/blob/9c92d5592e852183c30b20193970bfc1afef2596/src/Generators/HtmlGenerator.php#L259-L272 | train |
chameleon-system/chameleon-shop | src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/WebModules/MTExtranetRegistrationGuestCore/MTExtranetRegistrationGuestCore.class.php | MTExtranetRegistrationGuestCore.RegisterGuestUser | protected function RegisterGuestUser($sSuccessURL = null, $sFailureURL = null)
{
if (null === $sSuccessURL) {
if ($this->global->UserDataExists('sSuccessURL')) {
$sSuccessURL = $this->global->GetUserData('sSuccessURL', array(), TCMSUserInput::FILTER_URL);
}
if (empty($sSuccessURL)) {
$sSuccessURL = null;
}
}
if (null === $sFailureURL) {
if ($this->global->UserDataExists('sFailureURL')) {
$sFailureURL = $this->global->GetUserData('sFailureURL', array(), TCMSUserInput::FILTER_URL);
}
if (empty($sFailureURL)) {
$sFailureURL = null;
}
}
$oStep = TdbShopOrderStep::GetStep('thankyou');
if (null !== $oStep) {
$oTmpUser = $oStep->GetLastUserBoughtFromSession();
$aData = $this->GetFilteredUserData('aUser');
if (is_array($aData) && 2 == count($aData) && array_key_exists('password', $aData) && array_key_exists('password2', $aData)) {
foreach ($aData as $key => $val) {
$oTmpUser->sqlData[$key] = trim($val);
}
$aData = $oTmpUser->sqlData;
$extranetUserProvider = $this->getExtranetUserProvider();
$extranetUserProvider->reset();
$oUser = $extranetUserProvider->getActiveUser();
$oUser->LoadFromRow($aData);
$bDataValid = $this->ValidateUserLoginData();
$bDataValid = $this->ValidateUserData() && $bDataValid;
if ($bDataValid) {
$oUserOrder = &TShopBasket::GetLastCreatedOrder();
$sNewUserId = $oUser->Register();
$this->UpdateUserAddress(null, null, true);
$oUserOrder->AllowEditByAll(true);
$oUserOrder->SaveFieldsFast(array('data_extranet_user_id' => $sNewUserId));
$oUserOrder->AllowEditByAll(false);
if (!is_null($sSuccessURL)) {
$this->controller->HeaderURLRedirect($sSuccessURL, true);
} else {
$oExtranetConf = &TdbDataExtranet::GetInstance();
$this->controller->HeaderURLRedirect($oExtranetConf->GetLinkRegisterSuccessPage(), true);
}
$oStep->RemoveLastUserBoughtFromSession();
}
}
}
if (null !== $sFailureURL) {
$this->controller->HeaderURLRedirect($sFailureURL, true);
} else {
$oUser = TdbDataExtranetUser::GetInstance();
$this->controller->HeaderURLRedirect($oUser->GetLinkForRegistrationGuest(), true);
}
} | php | protected function RegisterGuestUser($sSuccessURL = null, $sFailureURL = null)
{
if (null === $sSuccessURL) {
if ($this->global->UserDataExists('sSuccessURL')) {
$sSuccessURL = $this->global->GetUserData('sSuccessURL', array(), TCMSUserInput::FILTER_URL);
}
if (empty($sSuccessURL)) {
$sSuccessURL = null;
}
}
if (null === $sFailureURL) {
if ($this->global->UserDataExists('sFailureURL')) {
$sFailureURL = $this->global->GetUserData('sFailureURL', array(), TCMSUserInput::FILTER_URL);
}
if (empty($sFailureURL)) {
$sFailureURL = null;
}
}
$oStep = TdbShopOrderStep::GetStep('thankyou');
if (null !== $oStep) {
$oTmpUser = $oStep->GetLastUserBoughtFromSession();
$aData = $this->GetFilteredUserData('aUser');
if (is_array($aData) && 2 == count($aData) && array_key_exists('password', $aData) && array_key_exists('password2', $aData)) {
foreach ($aData as $key => $val) {
$oTmpUser->sqlData[$key] = trim($val);
}
$aData = $oTmpUser->sqlData;
$extranetUserProvider = $this->getExtranetUserProvider();
$extranetUserProvider->reset();
$oUser = $extranetUserProvider->getActiveUser();
$oUser->LoadFromRow($aData);
$bDataValid = $this->ValidateUserLoginData();
$bDataValid = $this->ValidateUserData() && $bDataValid;
if ($bDataValid) {
$oUserOrder = &TShopBasket::GetLastCreatedOrder();
$sNewUserId = $oUser->Register();
$this->UpdateUserAddress(null, null, true);
$oUserOrder->AllowEditByAll(true);
$oUserOrder->SaveFieldsFast(array('data_extranet_user_id' => $sNewUserId));
$oUserOrder->AllowEditByAll(false);
if (!is_null($sSuccessURL)) {
$this->controller->HeaderURLRedirect($sSuccessURL, true);
} else {
$oExtranetConf = &TdbDataExtranet::GetInstance();
$this->controller->HeaderURLRedirect($oExtranetConf->GetLinkRegisterSuccessPage(), true);
}
$oStep->RemoveLastUserBoughtFromSession();
}
}
}
if (null !== $sFailureURL) {
$this->controller->HeaderURLRedirect($sFailureURL, true);
} else {
$oUser = TdbDataExtranetUser::GetInstance();
$this->controller->HeaderURLRedirect($oUser->GetLinkForRegistrationGuest(), true);
}
} | [
"protected",
"function",
"RegisterGuestUser",
"(",
"$",
"sSuccessURL",
"=",
"null",
",",
"$",
"sFailureURL",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"sSuccessURL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"global",
"->",
"UserDataExists",
"(... | Register guest user. Requires last basket step to be thankyou.
@param null $sSuccessURL
@param null $sFailureURL | [
"Register",
"guest",
"user",
".",
"Requires",
"last",
"basket",
"step",
"to",
"be",
"thankyou",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/WebModules/MTExtranetRegistrationGuestCore/MTExtranetRegistrationGuestCore.class.php#L39-L96 | train |
chameleon-system/chameleon-shop | src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/WebModules/MTExtranetRegistrationGuestCore/MTExtranetRegistrationGuestCore.class.php | MTExtranetRegistrationGuestCore.HandleRegisterAfterShopping | protected function HandleRegisterAfterShopping()
{
if ($this->ActivePageIsRegisterAfterShopping()) {
if (!$this->IsAllowedToShowRegisterAfterShoppingPage()) {
$oExtranetConfig = TdbDataExtranet::GetInstance();
$this->controller->HeaderURLRedirect($oExtranetConfig->GetLinkAccessDeniedPage(), true);
}
}
} | php | protected function HandleRegisterAfterShopping()
{
if ($this->ActivePageIsRegisterAfterShopping()) {
if (!$this->IsAllowedToShowRegisterAfterShoppingPage()) {
$oExtranetConfig = TdbDataExtranet::GetInstance();
$this->controller->HeaderURLRedirect($oExtranetConfig->GetLinkAccessDeniedPage(), true);
}
}
} | [
"protected",
"function",
"HandleRegisterAfterShopping",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ActivePageIsRegisterAfterShopping",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"IsAllowedToShowRegisterAfterShoppingPage",
"(",
")",
")",
"{",
"$",
... | if user is not allowed to be register redirect to access denied page. | [
"if",
"user",
"is",
"not",
"allowed",
"to",
"be",
"register",
"redirect",
"to",
"access",
"denied",
"page",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/WebModules/MTExtranetRegistrationGuestCore/MTExtranetRegistrationGuestCore.class.php#L101-L109 | train |
chameleon-system/chameleon-shop | src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/WebModules/MTExtranetRegistrationGuestCore/MTExtranetRegistrationGuestCore.class.php | MTExtranetRegistrationGuestCore.IsAllowedToShowRegisterAfterShoppingPage | protected function IsAllowedToShowRegisterAfterShoppingPage()
{
$oStep = TdbShopOrderStep::GetStep('thankyou');
$bUserIsValid = false;
if (!is_null($oStep)) {
$oUser = $oStep->GetLastUserBoughtFromSession();
if (!is_null($oUser)) {
$bUserIsValid = $this->ValidateGivenUserData($oUser);
if ($bUserIsValid) {
$oUserOrder = &TShopBasket::GetLastCreatedOrder();
if ($oUser->LoginExists()) {
$bUserIsValid = false;
}
if (is_null($oUserOrder)) {
$bUserIsValid = false;
}
}
}
}
return $bUserIsValid;
} | php | protected function IsAllowedToShowRegisterAfterShoppingPage()
{
$oStep = TdbShopOrderStep::GetStep('thankyou');
$bUserIsValid = false;
if (!is_null($oStep)) {
$oUser = $oStep->GetLastUserBoughtFromSession();
if (!is_null($oUser)) {
$bUserIsValid = $this->ValidateGivenUserData($oUser);
if ($bUserIsValid) {
$oUserOrder = &TShopBasket::GetLastCreatedOrder();
if ($oUser->LoginExists()) {
$bUserIsValid = false;
}
if (is_null($oUserOrder)) {
$bUserIsValid = false;
}
}
}
}
return $bUserIsValid;
} | [
"protected",
"function",
"IsAllowedToShowRegisterAfterShoppingPage",
"(",
")",
"{",
"$",
"oStep",
"=",
"TdbShopOrderStep",
"::",
"GetStep",
"(",
"'thankyou'",
")",
";",
"$",
"bUserIsValid",
"=",
"false",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"oStep",
")",
... | Checks if user is allowed to register after shopping.
@return bool | [
"Checks",
"if",
"user",
"is",
"allowed",
"to",
"register",
"after",
"shopping",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/WebModules/MTExtranetRegistrationGuestCore/MTExtranetRegistrationGuestCore.class.php#L116-L137 | train |
chameleon-system/chameleon-shop | src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/WebModules/MTExtranetRegistrationGuestCore/MTExtranetRegistrationGuestCore.class.php | MTExtranetRegistrationGuestCore.ActivePageIsRegisterAfterShopping | protected function ActivePageIsRegisterAfterShopping()
{
$bActivePageIsRegisterAfterShopping = false;
$oURLData = TCMSSmartURLData::GetActive();
$oShop = TdbShop::GetInstance($oURLData->iPortalId);
$sNodeId = $oShop->GetSystemPageNodeId('register-after-shopping');
$oActivePage = $this->getActivePageService()->getActivePage();
if ($oActivePage && $sNodeId == $oActivePage->GetMainTreeId()) {
$bActivePageIsRegisterAfterShopping = true;
}
return $bActivePageIsRegisterAfterShopping;
} | php | protected function ActivePageIsRegisterAfterShopping()
{
$bActivePageIsRegisterAfterShopping = false;
$oURLData = TCMSSmartURLData::GetActive();
$oShop = TdbShop::GetInstance($oURLData->iPortalId);
$sNodeId = $oShop->GetSystemPageNodeId('register-after-shopping');
$oActivePage = $this->getActivePageService()->getActivePage();
if ($oActivePage && $sNodeId == $oActivePage->GetMainTreeId()) {
$bActivePageIsRegisterAfterShopping = true;
}
return $bActivePageIsRegisterAfterShopping;
} | [
"protected",
"function",
"ActivePageIsRegisterAfterShopping",
"(",
")",
"{",
"$",
"bActivePageIsRegisterAfterShopping",
"=",
"false",
";",
"$",
"oURLData",
"=",
"TCMSSmartURLData",
"::",
"GetActive",
"(",
")",
";",
"$",
"oShop",
"=",
"TdbShop",
"::",
"GetInstance",
... | Checks if active page is register guest page.
@return bool | [
"Checks",
"if",
"active",
"page",
"is",
"register",
"guest",
"page",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ExtranetRegistrationGuestBundle/pkgExtranet/objects/WebModules/MTExtranetRegistrationGuestCore/MTExtranetRegistrationGuestCore.class.php#L166-L178 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/RefundExample.php | RefundExample.getOrderReferenceDetails | public function getOrderReferenceDetails()
{
$getOrderReferenceDetailsRequest
= new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest();
$getOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
$getOrderReferenceDetailsRequest->setAmazonOrderReferenceId(
$this->_amazonOrderReferenceId
);
return $this->_service->getOrderReferenceDetails(
$getOrderReferenceDetailsRequest
);
} | php | public function getOrderReferenceDetails()
{
$getOrderReferenceDetailsRequest
= new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest();
$getOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
$getOrderReferenceDetailsRequest->setAmazonOrderReferenceId(
$this->_amazonOrderReferenceId
);
return $this->_service->getOrderReferenceDetails(
$getOrderReferenceDetailsRequest
);
} | [
"public",
"function",
"getOrderReferenceDetails",
"(",
")",
"{",
"$",
"getOrderReferenceDetailsRequest",
"=",
"new",
"OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest",
"(",
")",
";",
"$",
"getOrderReferenceDetailsRequest",
"->",
"setSellerId",
"(",
"$",
"this",... | Get the order reference details to find to the state
of the order reference
@return OffAmazonPaymentsService_Model_GetOrderReferenceDetailsResponse response | [
"Get",
"the",
"order",
"reference",
"details",
"to",
"find",
"to",
"the",
"state",
"of",
"the",
"order",
"reference"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/RefundExample.php#L80-L92 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/RefundExample.php | RefundExample.getCaptureDetailsRequest | public function getCaptureDetailsRequest()
{
$getCaptureDetailsRequest
= new OffAmazonPaymentsService_Model_GetCaptureDetailsRequest();
$getCaptureDetailsRequest->setSellerId($this->_sellerId);
$getCaptureDetailsRequest->setAmazonCaptureId($this->_amazonCaptureId);
return $this->_service->getCaptureDetails($getCaptureDetailsRequest);
} | php | public function getCaptureDetailsRequest()
{
$getCaptureDetailsRequest
= new OffAmazonPaymentsService_Model_GetCaptureDetailsRequest();
$getCaptureDetailsRequest->setSellerId($this->_sellerId);
$getCaptureDetailsRequest->setAmazonCaptureId($this->_amazonCaptureId);
return $this->_service->getCaptureDetails($getCaptureDetailsRequest);
} | [
"public",
"function",
"getCaptureDetailsRequest",
"(",
")",
"{",
"$",
"getCaptureDetailsRequest",
"=",
"new",
"OffAmazonPaymentsService_Model_GetCaptureDetailsRequest",
"(",
")",
";",
"$",
"getCaptureDetailsRequest",
"->",
"setSellerId",
"(",
"$",
"this",
"->",
"_sellerId... | Get the capture details to find out the
maximum amount that can be refunded
@return OffAmazonPaymentsService_Model_GetCaptureDetailsResponse response | [
"Get",
"the",
"capture",
"details",
"to",
"find",
"out",
"the",
"maximum",
"amount",
"that",
"can",
"be",
"refunded"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/RefundExample.php#L100-L108 | train |
chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/RefundExample.php | RefundExample.getRefundDetails | public function getRefundDetails($amazonRefundId)
{
$getRefundDetailsRequest
= new OffAmazonPaymentsService_Model_GetRefundDetailsRequest();
$getRefundDetailsRequest->setSellerId($this->_sellerId);
$getRefundDetailsRequest->setAmazonRefundId($amazonRefundId);
return $this->_service->getRefundDetails($getRefundDetailsRequest);
} | php | public function getRefundDetails($amazonRefundId)
{
$getRefundDetailsRequest
= new OffAmazonPaymentsService_Model_GetRefundDetailsRequest();
$getRefundDetailsRequest->setSellerId($this->_sellerId);
$getRefundDetailsRequest->setAmazonRefundId($amazonRefundId);
return $this->_service->getRefundDetails($getRefundDetailsRequest);
} | [
"public",
"function",
"getRefundDetails",
"(",
"$",
"amazonRefundId",
")",
"{",
"$",
"getRefundDetailsRequest",
"=",
"new",
"OffAmazonPaymentsService_Model_GetRefundDetailsRequest",
"(",
")",
";",
"$",
"getRefundDetailsRequest",
"->",
"setSellerId",
"(",
"$",
"this",
"-... | Perform the getRefundDetails request for the order
@param string $amazonRefundId authorization transaction
to query
@return OffAmazonPaymentsService_Model_GetRefundDetailsResponse response | [
"Perform",
"the",
"getRefundDetails",
"request",
"for",
"the",
"order"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/RefundExample.php#L180-L187 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopOrderEndPoint.class.php | TCMSTableEditorShopOrderEndPoint.ShopOrderSendConfirmOrderMail | public function ShopOrderSendConfirmOrderMail($sMail = null)
{
$oGlobal = TGlobal::instance();
if (is_null($sMail)) {
$sMail = $oGlobal->GetUserData('sTargetMail');
}
$oReturnData = $this->GetObjectShortInfo();
$oReturnData->sTargetMail = $sMail;
$bSuccess = false;
$oOrder = TdbShopOrder::GetNewInstance();
/** @var $oOrder TdbShopOrder */
$oOrder->AllowEditByAll(true);
if (!$oOrder->Load($this->sId)) {
$oOrder = null;
} else {
$bSuccess = $oOrder->SendOrderNotification($sMail);
}
if (true === $bSuccess) {
$oReturnData->bSuccess = true;
$oReturnData->sMessage = TGlobal::Translate('chameleon_system_shop.orders.msg_order_confirm_sent', array('%mail%' => $sMail));
} else {
$oReturnData->bSuccess = false;
$oReturnData->sMessage = TGlobal::Translate('chameleon_system_shop.orders.error_sending_confirm_mail', array('%error%' => $bSuccess));
}
return $oReturnData;
} | php | public function ShopOrderSendConfirmOrderMail($sMail = null)
{
$oGlobal = TGlobal::instance();
if (is_null($sMail)) {
$sMail = $oGlobal->GetUserData('sTargetMail');
}
$oReturnData = $this->GetObjectShortInfo();
$oReturnData->sTargetMail = $sMail;
$bSuccess = false;
$oOrder = TdbShopOrder::GetNewInstance();
/** @var $oOrder TdbShopOrder */
$oOrder->AllowEditByAll(true);
if (!$oOrder->Load($this->sId)) {
$oOrder = null;
} else {
$bSuccess = $oOrder->SendOrderNotification($sMail);
}
if (true === $bSuccess) {
$oReturnData->bSuccess = true;
$oReturnData->sMessage = TGlobal::Translate('chameleon_system_shop.orders.msg_order_confirm_sent', array('%mail%' => $sMail));
} else {
$oReturnData->bSuccess = false;
$oReturnData->sMessage = TGlobal::Translate('chameleon_system_shop.orders.error_sending_confirm_mail', array('%error%' => $bSuccess));
}
return $oReturnData;
} | [
"public",
"function",
"ShopOrderSendConfirmOrderMail",
"(",
"$",
"sMail",
"=",
"null",
")",
"{",
"$",
"oGlobal",
"=",
"TGlobal",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"sMail",
")",
")",
"{",
"$",
"sMail",
"=",
"$",
"oGlobal",... | send the current order to the email.
@param string $sMail - can also be passed via get/post | [
"send",
"the",
"current",
"order",
"to",
"the",
"email",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopOrderEndPoint.class.php#L50-L78 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopOrderEndPoint.class.php | TCMSTableEditorShopOrderEndPoint.GetFrontendActionUrlToSendOrderEmail | public function GetFrontendActionUrlToSendOrderEmail($sMail = null)
{
$sURL = '';
if (is_null($sMail)) {
$oGlobal = \ChameleonSystem\CoreBundle\ServiceLocator::get('chameleon_system_core.global');
$sMail = $oGlobal->GetUserData('sTargetMail');
}
if (!empty($sMail) && is_object($this->oTable)) {
$sPortalId = $this->oTable->fieldCmsPortalId;
if (empty($this->oTable->fieldCmsPortalId)) {
$oPortal = $this->getPortalDomainService()->getActivePortal();
$sPortalId = $oPortal->id;
}
$oAction = TdbPkgRunFrontendAction::CreateAction('TPkgRunFrontendAction_SendOrderEMail', $sPortalId, array('email' => $sMail, 'order_id' => $this->sId));
$sURL = $oAction->getUrlToRunAction();
}
return $sURL;
} | php | public function GetFrontendActionUrlToSendOrderEmail($sMail = null)
{
$sURL = '';
if (is_null($sMail)) {
$oGlobal = \ChameleonSystem\CoreBundle\ServiceLocator::get('chameleon_system_core.global');
$sMail = $oGlobal->GetUserData('sTargetMail');
}
if (!empty($sMail) && is_object($this->oTable)) {
$sPortalId = $this->oTable->fieldCmsPortalId;
if (empty($this->oTable->fieldCmsPortalId)) {
$oPortal = $this->getPortalDomainService()->getActivePortal();
$sPortalId = $oPortal->id;
}
$oAction = TdbPkgRunFrontendAction::CreateAction('TPkgRunFrontendAction_SendOrderEMail', $sPortalId, array('email' => $sMail, 'order_id' => $this->sId));
$sURL = $oAction->getUrlToRunAction();
}
return $sURL;
} | [
"public",
"function",
"GetFrontendActionUrlToSendOrderEmail",
"(",
"$",
"sMail",
"=",
"null",
")",
"{",
"$",
"sURL",
"=",
"''",
";",
"if",
"(",
"is_null",
"(",
"$",
"sMail",
")",
")",
"{",
"$",
"oGlobal",
"=",
"\\",
"ChameleonSystem",
"\\",
"CoreBundle",
... | send order notification for current order from backend - uses frontend action,
so portal and snippets are set correctly.
@param string $sMail - can also be passed via get/post
@return string | [
"send",
"order",
"notification",
"for",
"current",
"order",
"from",
"backend",
"-",
"uses",
"frontend",
"action",
"so",
"portal",
"and",
"snippets",
"are",
"set",
"correctly",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopOrderEndPoint.class.php#L88-L106 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopOrderEndPoint.class.php | TCMSTableEditorShopOrderEndPoint.DeleteExecute | protected function DeleteExecute()
{
$oOrder = clone $this->oTable;
$bReturn = parent::DeleteExecute();
if (!empty($oOrder->sqlData['data_extranet_user_id'])) {
$oTmpuser = TdbDataExtranetUser::GetNewInstance();
$oTmpuser->Load($oOrder->sqlData['data_extranet_user_id']);
if (!is_null($oTmpuser)) {
TdbDataExtranetGroup::UpdateAutoAssignToUser($oTmpuser);
}
}
return $bReturn;
} | php | protected function DeleteExecute()
{
$oOrder = clone $this->oTable;
$bReturn = parent::DeleteExecute();
if (!empty($oOrder->sqlData['data_extranet_user_id'])) {
$oTmpuser = TdbDataExtranetUser::GetNewInstance();
$oTmpuser->Load($oOrder->sqlData['data_extranet_user_id']);
if (!is_null($oTmpuser)) {
TdbDataExtranetGroup::UpdateAutoAssignToUser($oTmpuser);
}
}
return $bReturn;
} | [
"protected",
"function",
"DeleteExecute",
"(",
")",
"{",
"$",
"oOrder",
"=",
"clone",
"$",
"this",
"->",
"oTable",
";",
"$",
"bReturn",
"=",
"parent",
"::",
"DeleteExecute",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"oOrder",
"->",
"sqlData",
... | is called only from Delete method and calls all delete relevant methods
executes the final SQL Delete Query. | [
"is",
"called",
"only",
"from",
"Delete",
"method",
"and",
"calls",
"all",
"delete",
"relevant",
"methods",
"executes",
"the",
"final",
"SQL",
"Delete",
"Query",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopOrderEndPoint.class.php#L156-L169 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TPkgShop_CmsLanguage.class.php | TPkgShop_CmsLanguage.GetTranslatedPageURL | public function GetTranslatedPageURL()
{
$sTranslatesPageURL = '';
$this->TargetLanguageSimulation(true);
// product page
$oActiveProduct = TdbShop::GetActiveItem();
if (is_object($oActiveProduct)) {
$oNewProduct = TdbShopArticle::GetNewInstance($oActiveProduct->id, $this->id);
$oActiveProductCategory = TdbShop::GetActiveCategory();
$sCatId = null;
if (is_object($oActiveProductCategory)) {
$sCatId = $oActiveProductCategory->id;
}
$sTranslatesPageURL = $oNewProduct->GetDetailLink(true, $sCatId);
}
// category page?
if (empty($sTranslatesPageURL)) {
$oActiveProductCategory = TdbShop::GetActiveCategory();
if (is_object($oActiveProductCategory)) {
$oNewProductCategory = TdbShopCategory::GetNewInstance($oActiveProductCategory->id, $this->id);
$sTranslatesPageURL = $oNewProductCategory->GetLink(true);
}
}
$this->TargetLanguageSimulation(false);
// shop basket wizard?
if (empty($sTranslatesPageURL)) {
$oGlobal = TGlobal::instance();
$sStepName = $oGlobal->GetUserData(MTShopOrderWizardCore::URL_PARAM_STEP_SYSTEM_NAME);
if (!empty($sStepName)) {
$oActiveStep = TdbShopOrderStep::GetStep($sStepName);
$sTranslatesPageURL = $this->getOrderStepPageService()->getLinkToOrderStepPageAbsolute($oActiveStep, array(), null, $this);
}
}
if (empty($sTranslatesPageURL)) {
$sTranslatesPageURL = parent::GetTranslatedPageURL();
}
return $sTranslatesPageURL;
} | php | public function GetTranslatedPageURL()
{
$sTranslatesPageURL = '';
$this->TargetLanguageSimulation(true);
// product page
$oActiveProduct = TdbShop::GetActiveItem();
if (is_object($oActiveProduct)) {
$oNewProduct = TdbShopArticle::GetNewInstance($oActiveProduct->id, $this->id);
$oActiveProductCategory = TdbShop::GetActiveCategory();
$sCatId = null;
if (is_object($oActiveProductCategory)) {
$sCatId = $oActiveProductCategory->id;
}
$sTranslatesPageURL = $oNewProduct->GetDetailLink(true, $sCatId);
}
// category page?
if (empty($sTranslatesPageURL)) {
$oActiveProductCategory = TdbShop::GetActiveCategory();
if (is_object($oActiveProductCategory)) {
$oNewProductCategory = TdbShopCategory::GetNewInstance($oActiveProductCategory->id, $this->id);
$sTranslatesPageURL = $oNewProductCategory->GetLink(true);
}
}
$this->TargetLanguageSimulation(false);
// shop basket wizard?
if (empty($sTranslatesPageURL)) {
$oGlobal = TGlobal::instance();
$sStepName = $oGlobal->GetUserData(MTShopOrderWizardCore::URL_PARAM_STEP_SYSTEM_NAME);
if (!empty($sStepName)) {
$oActiveStep = TdbShopOrderStep::GetStep($sStepName);
$sTranslatesPageURL = $this->getOrderStepPageService()->getLinkToOrderStepPageAbsolute($oActiveStep, array(), null, $this);
}
}
if (empty($sTranslatesPageURL)) {
$sTranslatesPageURL = parent::GetTranslatedPageURL();
}
return $sTranslatesPageURL;
} | [
"public",
"function",
"GetTranslatedPageURL",
"(",
")",
"{",
"$",
"sTranslatesPageURL",
"=",
"''",
";",
"$",
"this",
"->",
"TargetLanguageSimulation",
"(",
"true",
")",
";",
"// product page",
"$",
"oActiveProduct",
"=",
"TdbShop",
"::",
"GetActiveItem",
"(",
")... | Return translated page URL.
@return string | [
"Return",
"translated",
"page",
"URL",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TPkgShop_CmsLanguage.class.php#L21-L65 | train |
edmondscommerce/doctrine-static-meta | src/Container.php | Container.addConfiguration | final public function addConfiguration(ContainerBuilder $containerBuilder, array $server): void
{
$this->autoWireServices($containerBuilder);
$this->defineConfig($containerBuilder, $server);
$this->defineCache($containerBuilder, $server);
$this->defineEntityManager($containerBuilder);
$this->configureValidationComponents($containerBuilder);
$this->defineAliases($containerBuilder);
$this->registerCustomFakerDataFillers($containerBuilder);
} | php | final public function addConfiguration(ContainerBuilder $containerBuilder, array $server): void
{
$this->autoWireServices($containerBuilder);
$this->defineConfig($containerBuilder, $server);
$this->defineCache($containerBuilder, $server);
$this->defineEntityManager($containerBuilder);
$this->configureValidationComponents($containerBuilder);
$this->defineAliases($containerBuilder);
$this->registerCustomFakerDataFillers($containerBuilder);
} | [
"final",
"public",
"function",
"addConfiguration",
"(",
"ContainerBuilder",
"$",
"containerBuilder",
",",
"array",
"$",
"server",
")",
":",
"void",
"{",
"$",
"this",
"->",
"autoWireServices",
"(",
"$",
"containerBuilder",
")",
";",
"$",
"this",
"->",
"defineCo... | Build all the definitions, alias and other configuration for this container. Each of these steps need to be
carried out to allow the everything to work, however you may wish to change individual bits. Therefore this
method has been made final, but the individual methods can be overwritten if you extend off the class
@param ContainerBuilder $containerBuilder
@param array $server
@throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
@throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException | [
"Build",
"all",
"the",
"definitions",
"alias",
"and",
"other",
"configuration",
"for",
"this",
"container",
".",
"Each",
"of",
"these",
"steps",
"need",
"to",
"be",
"carried",
"out",
"to",
"allow",
"the",
"everything",
"to",
"work",
"however",
"you",
"may",
... | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Container.php#L348-L357 | train |
edmondscommerce/doctrine-static-meta | src/Container.php | Container.autoWireServices | public function autoWireServices(ContainerBuilder $containerBuilder): void
{
$services = $this->getServices();
foreach ($services as $class) {
$containerBuilder->autowire($class, $class)->setPublic(true);
}
} | php | public function autoWireServices(ContainerBuilder $containerBuilder): void
{
$services = $this->getServices();
foreach ($services as $class) {
$containerBuilder->autowire($class, $class)->setPublic(true);
}
} | [
"public",
"function",
"autoWireServices",
"(",
"ContainerBuilder",
"$",
"containerBuilder",
")",
":",
"void",
"{",
"$",
"services",
"=",
"$",
"this",
"->",
"getServices",
"(",
")",
";",
"foreach",
"(",
"$",
"services",
"as",
"$",
"class",
")",
"{",
"$",
... | This takes every class from the getServices method, auto wires them and marks them as public. You may wish to
override this if you want to mark certain classes as private
@param ContainerBuilder $containerBuilder | [
"This",
"takes",
"every",
"class",
"from",
"the",
"getServices",
"method",
"auto",
"wires",
"them",
"and",
"marks",
"them",
"as",
"public",
".",
"You",
"may",
"wish",
"to",
"override",
"this",
"if",
"you",
"want",
"to",
"mark",
"certain",
"classes",
"as",
... | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Container.php#L365-L371 | train |
edmondscommerce/doctrine-static-meta | src/Container.php | Container.defineEntityManager | public function defineEntityManager(ContainerBuilder $container): void
{
$container->getDefinition(EntityManagerInterface::class)
->addArgument(new Reference(Config::class))
->setFactory(
[
new Reference(EntityManagerFactory::class),
'getEntityManager',
]
);
} | php | public function defineEntityManager(ContainerBuilder $container): void
{
$container->getDefinition(EntityManagerInterface::class)
->addArgument(new Reference(Config::class))
->setFactory(
[
new Reference(EntityManagerFactory::class),
'getEntityManager',
]
);
} | [
"public",
"function",
"defineEntityManager",
"(",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"$",
"container",
"->",
"getDefinition",
"(",
"EntityManagerInterface",
"::",
"class",
")",
"->",
"addArgument",
"(",
"new",
"Reference",
"(",
"Config",
... | This is used to auto wire the entity manager. It first adds the DSM factory as the factory for the class, and
sets the Entity Manager as the implementation of the interface. Overrider this if you want to use your own
factory to create and configure the entity manager
@param ContainerBuilder $container | [
"This",
"is",
"used",
"to",
"auto",
"wire",
"the",
"entity",
"manager",
".",
"It",
"first",
"adds",
"the",
"DSM",
"factory",
"as",
"the",
"factory",
"for",
"the",
"class",
"and",
"sets",
"the",
"Entity",
"Manager",
"as",
"the",
"implementation",
"of",
"t... | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Container.php#L460-L470 | train |
edmondscommerce/doctrine-static-meta | src/Container.php | Container.configureValidationComponents | public function configureValidationComponents(ContainerBuilder $containerBuilder): void
{
$containerBuilder->getDefinition(EntityDataValidator::class)
->setFactory(
[
new Reference(EntityDataValidatorFactory::class),
'buildEntityDataValidator',
]
)->setShared(false);
} | php | public function configureValidationComponents(ContainerBuilder $containerBuilder): void
{
$containerBuilder->getDefinition(EntityDataValidator::class)
->setFactory(
[
new Reference(EntityDataValidatorFactory::class),
'buildEntityDataValidator',
]
)->setShared(false);
} | [
"public",
"function",
"configureValidationComponents",
"(",
"ContainerBuilder",
"$",
"containerBuilder",
")",
":",
"void",
"{",
"$",
"containerBuilder",
"->",
"getDefinition",
"(",
"EntityDataValidator",
"::",
"class",
")",
"->",
"setFactory",
"(",
"[",
"new",
"Refe... | Ensure we are using the container constraint validator factory so that custom validators with dependencies can
simply declare them as normal. Note that you will need to define each custom validator as a service in your
container.
@param ContainerBuilder $containerBuilder | [
"Ensure",
"we",
"are",
"using",
"the",
"container",
"constraint",
"validator",
"factory",
"so",
"that",
"custom",
"validators",
"with",
"dependencies",
"can",
"simply",
"declare",
"them",
"as",
"normal",
".",
"Note",
"that",
"you",
"will",
"need",
"to",
"defin... | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Container.php#L479-L488 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandler.class.php | TShopPaymentHandler.SetExecutePaymentInterrupt | public static function SetExecutePaymentInterrupt($bActive)
{
if ($bActive) {
$_SESSION[TdbShopPaymentHandler::CONTINUE_PAYMENT_EXECUTION_FLAG] = '1';
} else {
if (array_key_exists(TdbShopPaymentHandler::CONTINUE_PAYMENT_EXECUTION_FLAG, $_SESSION)) {
$_SESSION[TdbShopPaymentHandler::CONTINUE_PAYMENT_EXECUTION_FLAG] = '0';
unset($_SESSION[TdbShopPaymentHandler::CONTINUE_PAYMENT_EXECUTION_FLAG]);
}
}
} | php | public static function SetExecutePaymentInterrupt($bActive)
{
if ($bActive) {
$_SESSION[TdbShopPaymentHandler::CONTINUE_PAYMENT_EXECUTION_FLAG] = '1';
} else {
if (array_key_exists(TdbShopPaymentHandler::CONTINUE_PAYMENT_EXECUTION_FLAG, $_SESSION)) {
$_SESSION[TdbShopPaymentHandler::CONTINUE_PAYMENT_EXECUTION_FLAG] = '0';
unset($_SESSION[TdbShopPaymentHandler::CONTINUE_PAYMENT_EXECUTION_FLAG]);
}
}
} | [
"public",
"static",
"function",
"SetExecutePaymentInterrupt",
"(",
"$",
"bActive",
")",
"{",
"if",
"(",
"$",
"bActive",
")",
"{",
"$",
"_SESSION",
"[",
"TdbShopPaymentHandler",
"::",
"CONTINUE_PAYMENT_EXECUTION_FLAG",
"]",
"=",
"'1'",
";",
"}",
"else",
"{",
"i... | Set the ExecutePaymentInterrupt. If it is set to active, then the next request to the
basket page will auto.
@param bool $bActive | [
"Set",
"the",
"ExecutePaymentInterrupt",
".",
"If",
"it",
"is",
"set",
"to",
"active",
"then",
"the",
"next",
"request",
"to",
"the",
"basket",
"page",
"will",
"auto",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandler.class.php#L223-L233 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandler.class.php | TShopPaymentHandler.GetUserPaymentDataItem | public function GetUserPaymentDataItem($sItemName)
{
$aPaymentData = $this->GetUserPaymentData();
$sReturn = false;
if (is_array($aPaymentData) && isset($aPaymentData[$sItemName])) {
$sReturn = $aPaymentData[$sItemName];
}
return $sReturn;
} | php | public function GetUserPaymentDataItem($sItemName)
{
$aPaymentData = $this->GetUserPaymentData();
$sReturn = false;
if (is_array($aPaymentData) && isset($aPaymentData[$sItemName])) {
$sReturn = $aPaymentData[$sItemName];
}
return $sReturn;
} | [
"public",
"function",
"GetUserPaymentDataItem",
"(",
"$",
"sItemName",
")",
"{",
"$",
"aPaymentData",
"=",
"$",
"this",
"->",
"GetUserPaymentData",
"(",
")",
";",
"$",
"sReturn",
"=",
"false",
";",
"if",
"(",
"is_array",
"(",
"$",
"aPaymentData",
")",
"&&"... | return a variable from the user payment data. false if the variable is not found.
@param $sItemName
@return bool|string | [
"return",
"a",
"variable",
"from",
"the",
"user",
"payment",
"data",
".",
"false",
"if",
"the",
"variable",
"is",
"not",
"found",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandler.class.php#L366-L375 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandler.class.php | TShopPaymentHandler.Render | public function Render($sViewName = 'standard', $sViewType = 'Core', $aCallTimeVars = array())
{
$oView = new TViewParser();
$oShop = TdbShop::GetInstance();
$oView->AddVar('oShop', $oShop);
$oView->AddVar('oPaymentHandler', $this);
$aUserPaymentData = $this->GetUserPaymentData();
$oView->AddVar('aUserPaymentData', $aUserPaymentData);
$oView->AddVar('aCallTimeVars', $aCallTimeVars);
$aOtherParameters = $this->GetAdditionalViewVariables($sViewName, $sViewType);
$oView->AddVarArray($aOtherParameters);
return $oView->RenderObjectPackageView($sViewName, $this->GetViewPath(), $sViewType);
} | php | public function Render($sViewName = 'standard', $sViewType = 'Core', $aCallTimeVars = array())
{
$oView = new TViewParser();
$oShop = TdbShop::GetInstance();
$oView->AddVar('oShop', $oShop);
$oView->AddVar('oPaymentHandler', $this);
$aUserPaymentData = $this->GetUserPaymentData();
$oView->AddVar('aUserPaymentData', $aUserPaymentData);
$oView->AddVar('aCallTimeVars', $aCallTimeVars);
$aOtherParameters = $this->GetAdditionalViewVariables($sViewName, $sViewType);
$oView->AddVarArray($aOtherParameters);
return $oView->RenderObjectPackageView($sViewName, $this->GetViewPath(), $sViewType);
} | [
"public",
"function",
"Render",
"(",
"$",
"sViewName",
"=",
"'standard'",
",",
"$",
"sViewType",
"=",
"'Core'",
",",
"$",
"aCallTimeVars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"oView",
"=",
"new",
"TViewParser",
"(",
")",
";",
"$",
"oShop",
"=",
"T... | used to display the basket article list.
@param string $sViewName - the view to use
@param string $sViewType - where the view is located (Core, Custom-Core, Customer)
@param array $aCallTimeVars - place any custom vars that you want to pass through the call here
@return string | [
"used",
"to",
"display",
"the",
"basket",
"article",
"list",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandler.class.php#L407-L422 | train |
chameleon-system/chameleon-shop | src/ShopRatingServiceBundle/objects/webmodules/MTRatingList/MTRatingListCore.class.php | MTRatingListCore.SetActivePageSort | protected function SetActivePageSort()
{
$this->sActivePageSort = $this->GetUserInput('pagesort');
if (empty($this->sActivePageSort)) {
//load default
$this->sActivePageSort = $this->GetPageSortDefaultValue(); //default
$this->SetModuleSessionParameter('pagesort', $this->sActivePageSort);
} else {
$bFound = false;
foreach ($this->aPageSort as $iPsKey => $aPsVal) {
if (in_array($this->sActivePageSort, $aPsVal)) {
$bFound = true;
}
}
if (!$bFound) {
//try to load from session
$this->sActivePageSort = strtolower(trim($this->GetModuleSessionParameter('pagesort', false)));
if (!$this->sActivePageSort) {
$this->sActivePageSort = $this->aPageSort[1]['id'];
} //default
$this->SetModuleSessionParameter('pagesort', $this->sActivePageSort);
}
}
} | php | protected function SetActivePageSort()
{
$this->sActivePageSort = $this->GetUserInput('pagesort');
if (empty($this->sActivePageSort)) {
//load default
$this->sActivePageSort = $this->GetPageSortDefaultValue(); //default
$this->SetModuleSessionParameter('pagesort', $this->sActivePageSort);
} else {
$bFound = false;
foreach ($this->aPageSort as $iPsKey => $aPsVal) {
if (in_array($this->sActivePageSort, $aPsVal)) {
$bFound = true;
}
}
if (!$bFound) {
//try to load from session
$this->sActivePageSort = strtolower(trim($this->GetModuleSessionParameter('pagesort', false)));
if (!$this->sActivePageSort) {
$this->sActivePageSort = $this->aPageSort[1]['id'];
} //default
$this->SetModuleSessionParameter('pagesort', $this->sActivePageSort);
}
}
} | [
"protected",
"function",
"SetActivePageSort",
"(",
")",
"{",
"$",
"this",
"->",
"sActivePageSort",
"=",
"$",
"this",
"->",
"GetUserInput",
"(",
"'pagesort'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"sActivePageSort",
")",
")",
"{",
"//load de... | Set active page sort, load from user input, session, default. | [
"Set",
"active",
"page",
"sort",
"load",
"from",
"user",
"input",
"session",
"default",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopRatingServiceBundle/objects/webmodules/MTRatingList/MTRatingListCore.class.php#L43-L66 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopArticleGroupList.class.php | TShopArticleGroupList.& | public static function &GetArticleGroups($iArticleId)
{
$oList = null;
$query = "SELECT `shop_article_group`.*
FROM `shop_article_group`
INNER JOIN `shop_article_article_group_mlt` ON `shop_article_group`.`id` = `shop_article_article_group_mlt`.`target_id`
WHERE `shop_article_article_group_mlt`.`source_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($iArticleId)."'
ORDER BY `shop_article_group`.`name`
";
$oList = &TdbShopArticleGroupList::GetList($query);
return $oList;
} | php | public static function &GetArticleGroups($iArticleId)
{
$oList = null;
$query = "SELECT `shop_article_group`.*
FROM `shop_article_group`
INNER JOIN `shop_article_article_group_mlt` ON `shop_article_group`.`id` = `shop_article_article_group_mlt`.`target_id`
WHERE `shop_article_article_group_mlt`.`source_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($iArticleId)."'
ORDER BY `shop_article_group`.`name`
";
$oList = &TdbShopArticleGroupList::GetList($query);
return $oList;
} | [
"public",
"static",
"function",
"&",
"GetArticleGroups",
"(",
"$",
"iArticleId",
")",
"{",
"$",
"oList",
"=",
"null",
";",
"$",
"query",
"=",
"\"SELECT `shop_article_group`.*\n FROM `shop_article_group`\n INNER JOIN `shop_article_article_group_mlt` ON ... | return article group list for an article.
@param int $iArticleId
@return TdbShopArticleGroupList | [
"return",
"article",
"group",
"list",
"for",
"an",
"article",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopArticleGroupList.class.php#L21-L34 | train |
chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopArticleGroupList.class.php | TShopArticleGroupList.& | public function &GetMaxVat()
{
$iPointer = $this->getItemPointer();
$oMaxVatItem = null;
$this->GoToStart();
while ($oItem = &$this->Next()) {
$oCurrentVat = $oItem->GetVat();
if (!is_null($oCurrentVat)) {
if (is_null($oMaxVatItem)) {
$oMaxVatItem = $oCurrentVat;
} elseif ($oMaxVatItem->fieldVatPercent < $oCurrentVat->fieldVatPercent) {
$oMaxVatItem = $oCurrentVat;
}
}
}
$this->setItemPointer($iPointer);
return $oMaxVatItem;
} | php | public function &GetMaxVat()
{
$iPointer = $this->getItemPointer();
$oMaxVatItem = null;
$this->GoToStart();
while ($oItem = &$this->Next()) {
$oCurrentVat = $oItem->GetVat();
if (!is_null($oCurrentVat)) {
if (is_null($oMaxVatItem)) {
$oMaxVatItem = $oCurrentVat;
} elseif ($oMaxVatItem->fieldVatPercent < $oCurrentVat->fieldVatPercent) {
$oMaxVatItem = $oCurrentVat;
}
}
}
$this->setItemPointer($iPointer);
return $oMaxVatItem;
} | [
"public",
"function",
"&",
"GetMaxVat",
"(",
")",
"{",
"$",
"iPointer",
"=",
"$",
"this",
"->",
"getItemPointer",
"(",
")",
";",
"$",
"oMaxVatItem",
"=",
"null",
";",
"$",
"this",
"->",
"GoToStart",
"(",
")",
";",
"while",
"(",
"$",
"oItem",
"=",
"... | returns the max vat from the group list.
@return TdbShopVat | [
"returns",
"the",
"max",
"vat",
"from",
"the",
"group",
"list",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopArticleGroupList.class.php#L41-L59 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.cropSuffix | public function cropSuffix(string $fqn, string $suffix): string
{
if ($suffix === \substr($fqn, -\strlen($suffix))) {
return \substr($fqn, 0, -\strlen($suffix));
}
return $fqn;
} | php | public function cropSuffix(string $fqn, string $suffix): string
{
if ($suffix === \substr($fqn, -\strlen($suffix))) {
return \substr($fqn, 0, -\strlen($suffix));
}
return $fqn;
} | [
"public",
"function",
"cropSuffix",
"(",
"string",
"$",
"fqn",
",",
"string",
"$",
"suffix",
")",
":",
"string",
"{",
"if",
"(",
"$",
"suffix",
"===",
"\\",
"substr",
"(",
"$",
"fqn",
",",
"-",
"\\",
"strlen",
"(",
"$",
"suffix",
")",
")",
")",
"... | Crop a suffix from an FQN if it is there.
If it is not there, do nothing and return the FQN as is
@param string $fqn
@param string $suffix
@return string | [
"Crop",
"a",
"suffix",
"from",
"an",
"FQN",
"if",
"it",
"is",
"there",
"."
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L39-L46 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.basename | public function basename(string $namespace): string
{
$strrpos = \strrpos($namespace, '\\');
if (false === $strrpos) {
return $namespace;
}
return $this->tidy(\substr($namespace, $strrpos + 1));
} | php | public function basename(string $namespace): string
{
$strrpos = \strrpos($namespace, '\\');
if (false === $strrpos) {
return $namespace;
}
return $this->tidy(\substr($namespace, $strrpos + 1));
} | [
"public",
"function",
"basename",
"(",
"string",
"$",
"namespace",
")",
":",
"string",
"{",
"$",
"strrpos",
"=",
"\\",
"strrpos",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
";",
"if",
"(",
"false",
"===",
"$",
"strrpos",
")",
"{",
"return",
"$",
"nam... | Get the basename of a namespace
@param string $namespace
@return string | [
"Get",
"the",
"basename",
"of",
"a",
"namespace"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L97-L105 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getNamespaceRootToDirectoryFromFqn | public function getNamespaceRootToDirectoryFromFqn(string $fqn, string $directory): ?string
{
$strPos = \strrpos(
$fqn,
$directory
);
if (false !== $strPos) {
return $this->tidy(\substr($fqn, 0, $strPos + \strlen($directory)));
}
return null;
} | php | public function getNamespaceRootToDirectoryFromFqn(string $fqn, string $directory): ?string
{
$strPos = \strrpos(
$fqn,
$directory
);
if (false !== $strPos) {
return $this->tidy(\substr($fqn, 0, $strPos + \strlen($directory)));
}
return null;
} | [
"public",
"function",
"getNamespaceRootToDirectoryFromFqn",
"(",
"string",
"$",
"fqn",
",",
"string",
"$",
"directory",
")",
":",
"?",
"string",
"{",
"$",
"strPos",
"=",
"\\",
"strrpos",
"(",
"$",
"fqn",
",",
"$",
"directory",
")",
";",
"if",
"(",
"false... | Get the namespace root up to and including a specified directory
@param string $fqn
@param string $directory
@return null|string | [
"Get",
"the",
"namespace",
"root",
"up",
"to",
"and",
"including",
"a",
"specified",
"directory"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L174-L185 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getEntitySubNamespace | public function getEntitySubNamespace(
string $entityFqn
): string {
return $this->tidy(
\substr(
$entityFqn,
\strrpos(
$entityFqn,
'\\' . AbstractGenerator::ENTITIES_FOLDER_NAME . '\\'
)
+ \strlen('\\' . AbstractGenerator::ENTITIES_FOLDER_NAME . '\\')
)
);
} | php | public function getEntitySubNamespace(
string $entityFqn
): string {
return $this->tidy(
\substr(
$entityFqn,
\strrpos(
$entityFqn,
'\\' . AbstractGenerator::ENTITIES_FOLDER_NAME . '\\'
)
+ \strlen('\\' . AbstractGenerator::ENTITIES_FOLDER_NAME . '\\')
)
);
} | [
"public",
"function",
"getEntitySubNamespace",
"(",
"string",
"$",
"entityFqn",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"tidy",
"(",
"\\",
"substr",
"(",
"$",
"entityFqn",
",",
"\\",
"strrpos",
"(",
"$",
"entityFqn",
",",
"'\\\\'",
".",
"Ab... | Get the Namespace for an Entity, start from the Entities Fully Qualified Name base - normally
`\My\Project\Entities\`
@param string $entityFqn
@return string | [
"Get",
"the",
"Namespace",
"for",
"an",
"Entity",
"start",
"from",
"the",
"Entities",
"Fully",
"Qualified",
"Name",
"base",
"-",
"normally",
"\\",
"My",
"\\",
"Project",
"\\",
"Entities",
"\\"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L229-L242 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getTraitsNamespaceForEntity | public function getTraitsNamespaceForEntity(
string $entityFqn
): string {
$traitsNamespace = $this->getProjectNamespaceRootFromEntityFqn($entityFqn)
. AbstractGenerator::ENTITY_RELATIONS_NAMESPACE
. '\\' . $this->getEntitySubNamespace($entityFqn)
. '\\Traits';
return $traitsNamespace;
} | php | public function getTraitsNamespaceForEntity(
string $entityFqn
): string {
$traitsNamespace = $this->getProjectNamespaceRootFromEntityFqn($entityFqn)
. AbstractGenerator::ENTITY_RELATIONS_NAMESPACE
. '\\' . $this->getEntitySubNamespace($entityFqn)
. '\\Traits';
return $traitsNamespace;
} | [
"public",
"function",
"getTraitsNamespaceForEntity",
"(",
"string",
"$",
"entityFqn",
")",
":",
"string",
"{",
"$",
"traitsNamespace",
"=",
"$",
"this",
"->",
"getProjectNamespaceRootFromEntityFqn",
"(",
"$",
"entityFqn",
")",
".",
"AbstractGenerator",
"::",
"ENTITY... | Get the Fully Qualified Namespace root for Traits for the specified Entity
@param string $entityFqn
@return string | [
"Get",
"the",
"Fully",
"Qualified",
"Namespace",
"root",
"for",
"Traits",
"for",
"the",
"specified",
"Entity"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L251-L260 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getProjectNamespaceRootFromEntityFqn | public function getProjectNamespaceRootFromEntityFqn(string $entityFqn): string
{
return $this->tidy(
\substr(
$entityFqn,
0,
\strrpos(
$entityFqn,
'\\' . AbstractGenerator::ENTITIES_FOLDER_NAME . '\\'
)
)
);
} | php | public function getProjectNamespaceRootFromEntityFqn(string $entityFqn): string
{
return $this->tidy(
\substr(
$entityFqn,
0,
\strrpos(
$entityFqn,
'\\' . AbstractGenerator::ENTITIES_FOLDER_NAME . '\\'
)
)
);
} | [
"public",
"function",
"getProjectNamespaceRootFromEntityFqn",
"(",
"string",
"$",
"entityFqn",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"tidy",
"(",
"\\",
"substr",
"(",
"$",
"entityFqn",
",",
"0",
",",
"\\",
"strrpos",
"(",
"$",
"entityFqn",
... | Use the fully qualified name of two Entities to calculate the Project Namespace Root
- note: this assumes a single namespace level for entities, eg `Entities`
@param string $entityFqn
@return string | [
"Use",
"the",
"fully",
"qualified",
"name",
"of",
"two",
"Entities",
"to",
"calculate",
"the",
"Project",
"Namespace",
"Root"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L271-L283 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getHasPluralInterfaceFqnForEntity | public function getHasPluralInterfaceFqnForEntity(
string $entityFqn
): string {
$interfaceNamespace = $this->getInterfacesNamespaceForEntity($entityFqn);
return $interfaceNamespace . '\\Has' . ucfirst($entityFqn::getDoctrineStaticMeta()->getPlural()) . 'Interface';
} | php | public function getHasPluralInterfaceFqnForEntity(
string $entityFqn
): string {
$interfaceNamespace = $this->getInterfacesNamespaceForEntity($entityFqn);
return $interfaceNamespace . '\\Has' . ucfirst($entityFqn::getDoctrineStaticMeta()->getPlural()) . 'Interface';
} | [
"public",
"function",
"getHasPluralInterfaceFqnForEntity",
"(",
"string",
"$",
"entityFqn",
")",
":",
"string",
"{",
"$",
"interfaceNamespace",
"=",
"$",
"this",
"->",
"getInterfacesNamespaceForEntity",
"(",
"$",
"entityFqn",
")",
";",
"return",
"$",
"interfaceNames... | Get the Fully Qualified Namespace for the "HasEntities" interface for the specified Entity
@param string $entityFqn
@return string | [
"Get",
"the",
"Fully",
"Qualified",
"Namespace",
"for",
"the",
"HasEntities",
"interface",
"for",
"the",
"specified",
"Entity"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L292-L298 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getInterfacesNamespaceForEntity | public function getInterfacesNamespaceForEntity(
string $entityFqn
): string {
$interfacesNamespace = $this->getProjectNamespaceRootFromEntityFqn($entityFqn)
. AbstractGenerator::ENTITY_RELATIONS_NAMESPACE
. '\\' . $this->getEntitySubNamespace($entityFqn)
. '\\Interfaces';
return $this->tidy($interfacesNamespace);
} | php | public function getInterfacesNamespaceForEntity(
string $entityFqn
): string {
$interfacesNamespace = $this->getProjectNamespaceRootFromEntityFqn($entityFqn)
. AbstractGenerator::ENTITY_RELATIONS_NAMESPACE
. '\\' . $this->getEntitySubNamespace($entityFqn)
. '\\Interfaces';
return $this->tidy($interfacesNamespace);
} | [
"public",
"function",
"getInterfacesNamespaceForEntity",
"(",
"string",
"$",
"entityFqn",
")",
":",
"string",
"{",
"$",
"interfacesNamespace",
"=",
"$",
"this",
"->",
"getProjectNamespaceRootFromEntityFqn",
"(",
"$",
"entityFqn",
")",
".",
"AbstractGenerator",
"::",
... | Get the Fully Qualified Namespace root for Interfaces for the specified Entity
@param string $entityFqn
@return string | [
"Get",
"the",
"Fully",
"Qualified",
"Namespace",
"root",
"for",
"Interfaces",
"for",
"the",
"specified",
"Entity"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L307-L316 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getHasSingularInterfaceFqnForEntity | public function getHasSingularInterfaceFqnForEntity(
string $entityFqn
): string {
try {
$interfaceNamespace = $this->getInterfacesNamespaceForEntity($entityFqn);
return $interfaceNamespace . '\\Has' . ucfirst($entityFqn::getDoctrineStaticMeta()->getSingular())
. 'Interface';
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | php | public function getHasSingularInterfaceFqnForEntity(
string $entityFqn
): string {
try {
$interfaceNamespace = $this->getInterfacesNamespaceForEntity($entityFqn);
return $interfaceNamespace . '\\Has' . ucfirst($entityFqn::getDoctrineStaticMeta()->getSingular())
. 'Interface';
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | [
"public",
"function",
"getHasSingularInterfaceFqnForEntity",
"(",
"string",
"$",
"entityFqn",
")",
":",
"string",
"{",
"try",
"{",
"$",
"interfaceNamespace",
"=",
"$",
"this",
"->",
"getInterfacesNamespaceForEntity",
"(",
"$",
"entityFqn",
")",
";",
"return",
"$",... | Get the Fully Qualified Namespace for the "HasEntity" interface for the specified Entity
@param string $entityFqn
@return string
@throws DoctrineStaticMetaException | [
"Get",
"the",
"Fully",
"Qualified",
"Namespace",
"for",
"the",
"HasEntity",
"interface",
"for",
"the",
"specified",
"Entity"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L326-L341 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getProjectRootNamespaceFromComposerJson | public function getProjectRootNamespaceFromComposerJson(
string $dirForNamespace = 'src'
): string {
try {
$dirForNamespace = trim($dirForNamespace, '/');
$jsonPath = Config::getProjectRootDirectory() . '/composer.json';
$json = json_decode(\ts\file_get_contents($jsonPath), true);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \RuntimeException(
'Error decoding json from path ' . $jsonPath . ' , ' . json_last_error_msg()
);
}
/**
* @var string[][][][] $json
*/
if (isset($json['autoload']['psr-4'])) {
foreach ($json['autoload']['psr-4'] as $namespace => $dirs) {
foreach ($dirs as $dir) {
$dir = trim($dir, '/');
if ($dir === $dirForNamespace) {
return $this->tidy(rtrim($namespace, '\\'));
}
}
}
}
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
throw new DoctrineStaticMetaException('Failed to find psr-4 namespace root');
} | php | public function getProjectRootNamespaceFromComposerJson(
string $dirForNamespace = 'src'
): string {
try {
$dirForNamespace = trim($dirForNamespace, '/');
$jsonPath = Config::getProjectRootDirectory() . '/composer.json';
$json = json_decode(\ts\file_get_contents($jsonPath), true);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \RuntimeException(
'Error decoding json from path ' . $jsonPath . ' , ' . json_last_error_msg()
);
}
/**
* @var string[][][][] $json
*/
if (isset($json['autoload']['psr-4'])) {
foreach ($json['autoload']['psr-4'] as $namespace => $dirs) {
foreach ($dirs as $dir) {
$dir = trim($dir, '/');
if ($dir === $dirForNamespace) {
return $this->tidy(rtrim($namespace, '\\'));
}
}
}
}
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
throw new DoctrineStaticMetaException('Failed to find psr-4 namespace root');
} | [
"public",
"function",
"getProjectRootNamespaceFromComposerJson",
"(",
"string",
"$",
"dirForNamespace",
"=",
"'src'",
")",
":",
"string",
"{",
"try",
"{",
"$",
"dirForNamespace",
"=",
"trim",
"(",
"$",
"dirForNamespace",
",",
"'/'",
")",
";",
"$",
"jsonPath",
... | Read src autoloader from composer json
@param string $dirForNamespace
@return string
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess) | [
"Read",
"src",
"autoloader",
"from",
"composer",
"json"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L509-L542 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getOwningRelationsRootFqn | public function getOwningRelationsRootFqn(
string $projectRootNamespace,
array $subDirectories
): string {
$relationsRootFqn = $projectRootNamespace
. AbstractGenerator::ENTITY_RELATIONS_NAMESPACE . '\\';
if (count($subDirectories) > 0) {
$relationsRootFqn .= implode('\\', $subDirectories) . '\\';
}
return $this->tidy($relationsRootFqn);
} | php | public function getOwningRelationsRootFqn(
string $projectRootNamespace,
array $subDirectories
): string {
$relationsRootFqn = $projectRootNamespace
. AbstractGenerator::ENTITY_RELATIONS_NAMESPACE . '\\';
if (count($subDirectories) > 0) {
$relationsRootFqn .= implode('\\', $subDirectories) . '\\';
}
return $this->tidy($relationsRootFqn);
} | [
"public",
"function",
"getOwningRelationsRootFqn",
"(",
"string",
"$",
"projectRootNamespace",
",",
"array",
"$",
"subDirectories",
")",
":",
"string",
"{",
"$",
"relationsRootFqn",
"=",
"$",
"projectRootNamespace",
".",
"AbstractGenerator",
"::",
"ENTITY_RELATIONS_NAME... | Get the Namespace root for Entity Relations
@param string $projectRootNamespace
@param array $subDirectories
@return string | [
"Get",
"the",
"Namespace",
"root",
"for",
"Entity",
"Relations"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L594-L605 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getBaseHasTypeTraitFqn | public function getBaseHasTypeTraitFqn(
string $ownedHasName,
string $hasType
): string {
$required = \ts\stringContains($hasType, RelationsGenerator::PREFIX_REQUIRED)
? RelationsGenerator::PREFIX_REQUIRED
: '';
$hasType = \str_replace(RelationsGenerator::PREFIX_REQUIRED, '', $hasType);
foreach ([
RelationsGenerator::INTERNAL_TYPE_MANY_TO_MANY,
RelationsGenerator::INTERNAL_TYPE_ONE_TO_ONE,
] as $noStrip) {
if (\ts\stringContains($hasType, $noStrip)) {
return 'Has' . $required . $ownedHasName . $hasType;
}
}
foreach ([
RelationsGenerator::INTERNAL_TYPE_ONE_TO_MANY,
RelationsGenerator::INTERNAL_TYPE_MANY_TO_ONE,
] as $stripAll) {
if (\ts\stringContains($hasType, $stripAll)) {
return str_replace(
[
RelationsGenerator::PREFIX_OWNING,
RelationsGenerator::PREFIX_INVERSE,
],
'',
'Has' . $required . $ownedHasName . $hasType
);
}
}
return str_replace(
[
RelationsGenerator::PREFIX_INVERSE,
],
'',
'Has' . $required . $ownedHasName . $hasType
);
} | php | public function getBaseHasTypeTraitFqn(
string $ownedHasName,
string $hasType
): string {
$required = \ts\stringContains($hasType, RelationsGenerator::PREFIX_REQUIRED)
? RelationsGenerator::PREFIX_REQUIRED
: '';
$hasType = \str_replace(RelationsGenerator::PREFIX_REQUIRED, '', $hasType);
foreach ([
RelationsGenerator::INTERNAL_TYPE_MANY_TO_MANY,
RelationsGenerator::INTERNAL_TYPE_ONE_TO_ONE,
] as $noStrip) {
if (\ts\stringContains($hasType, $noStrip)) {
return 'Has' . $required . $ownedHasName . $hasType;
}
}
foreach ([
RelationsGenerator::INTERNAL_TYPE_ONE_TO_MANY,
RelationsGenerator::INTERNAL_TYPE_MANY_TO_ONE,
] as $stripAll) {
if (\ts\stringContains($hasType, $stripAll)) {
return str_replace(
[
RelationsGenerator::PREFIX_OWNING,
RelationsGenerator::PREFIX_INVERSE,
],
'',
'Has' . $required . $ownedHasName . $hasType
);
}
}
return str_replace(
[
RelationsGenerator::PREFIX_INVERSE,
],
'',
'Has' . $required . $ownedHasName . $hasType
);
} | [
"public",
"function",
"getBaseHasTypeTraitFqn",
"(",
"string",
"$",
"ownedHasName",
",",
"string",
"$",
"hasType",
")",
":",
"string",
"{",
"$",
"required",
"=",
"\\",
"ts",
"\\",
"stringContains",
"(",
"$",
"hasType",
",",
"RelationsGenerator",
"::",
"PREFIX_... | Normalise a has type, removing prefixes that are not required
Inverse hasTypes use the standard template without the prefix
The exclusion ot this are the ManyToMany and OneToOne relations
@param string $ownedHasName
@param string $hasType
@return string | [
"Normalise",
"a",
"has",
"type",
"removing",
"prefixes",
"that",
"are",
"not",
"required"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L618-L659 | train |
edmondscommerce/doctrine-static-meta | src/CodeGeneration/NamespaceHelper.php | NamespaceHelper.getOwningInterfaceFqn | public function getOwningInterfaceFqn(
string $hasType,
string $ownedEntityFqn,
string $projectRootNamespace = null,
string $srcFolder = AbstractCommand::DEFAULT_SRC_SUBFOLDER
): string {
try {
$ownedHasName = $this->getOwnedHasName($hasType, $ownedEntityFqn, $srcFolder, $projectRootNamespace);
if (null === $projectRootNamespace) {
$projectRootNamespace = $this->getProjectRootNamespaceFromComposerJson($srcFolder);
}
list($ownedClassName, , $ownedSubDirectories) = $this->parseFullyQualifiedName(
$ownedEntityFqn,
$srcFolder,
$projectRootNamespace
);
$interfaceSubDirectories = \array_slice($ownedSubDirectories, 2);
$owningInterfaceFqn = $this->getOwningRelationsRootFqn(
$projectRootNamespace,
$interfaceSubDirectories
);
$required = \ts\stringContains($hasType, RelationsGenerator::PREFIX_REQUIRED)
? 'Required'
: '';
$owningInterfaceFqn .= '\\' .
$ownedClassName .
'\\Interfaces\\Has' .
$required .
$ownedHasName .
'Interface';
return $this->tidy($owningInterfaceFqn);
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | php | public function getOwningInterfaceFqn(
string $hasType,
string $ownedEntityFqn,
string $projectRootNamespace = null,
string $srcFolder = AbstractCommand::DEFAULT_SRC_SUBFOLDER
): string {
try {
$ownedHasName = $this->getOwnedHasName($hasType, $ownedEntityFqn, $srcFolder, $projectRootNamespace);
if (null === $projectRootNamespace) {
$projectRootNamespace = $this->getProjectRootNamespaceFromComposerJson($srcFolder);
}
list($ownedClassName, , $ownedSubDirectories) = $this->parseFullyQualifiedName(
$ownedEntityFqn,
$srcFolder,
$projectRootNamespace
);
$interfaceSubDirectories = \array_slice($ownedSubDirectories, 2);
$owningInterfaceFqn = $this->getOwningRelationsRootFqn(
$projectRootNamespace,
$interfaceSubDirectories
);
$required = \ts\stringContains($hasType, RelationsGenerator::PREFIX_REQUIRED)
? 'Required'
: '';
$owningInterfaceFqn .= '\\' .
$ownedClassName .
'\\Interfaces\\Has' .
$required .
$ownedHasName .
'Interface';
return $this->tidy($owningInterfaceFqn);
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | [
"public",
"function",
"getOwningInterfaceFqn",
"(",
"string",
"$",
"hasType",
",",
"string",
"$",
"ownedEntityFqn",
",",
"string",
"$",
"projectRootNamespace",
"=",
"null",
",",
"string",
"$",
"srcFolder",
"=",
"AbstractCommand",
"::",
"DEFAULT_SRC_SUBFOLDER",
")",
... | Get the Fully Qualified Namespace for the Relation Interface for a specific Entity and hasType
@param string $hasType
@param string $ownedEntityFqn
@param string|null $projectRootNamespace
@param string $srcFolder
@return string
@throws DoctrineStaticMetaException | [
"Get",
"the",
"Fully",
"Qualified",
"Namespace",
"for",
"the",
"Relation",
"Interface",
"for",
"a",
"specific",
"Entity",
"and",
"hasType"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/NamespaceHelper.php#L729-L768 | train |
chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php | MTPkgShopArticleReviewCore.SetDefaultFieldVars | protected function SetDefaultFieldVars()
{
if ($this->global->UserDataExists(TdbShopArticleReview::INPUT_BASE_NAME)) {
$aPostUserData = $this->global->GetuserData(TdbShopArticleReview::INPUT_BASE_NAME);
}
$aDefaultFieldDataList = array('comment' => '', 'author_email' => '', 'author_name' => '', 'title' => '', 'send_comment_notification' => '0', 'rating' => 1);
if (isset($aPostUserData) && is_array($aPostUserData)) {
foreach ($aDefaultFieldDataList as $sDefaultFieldDataKey => $aDefaultFieldDataValue) {
if (!array_key_exists($sDefaultFieldDataKey, $aPostUserData)) {
$aPostUserData[$sDefaultFieldDataKey] = $aDefaultFieldDataValue;
}
}
$aDefaultFieldDataList = $aPostUserData;
}
return $aDefaultFieldDataList;
} | php | protected function SetDefaultFieldVars()
{
if ($this->global->UserDataExists(TdbShopArticleReview::INPUT_BASE_NAME)) {
$aPostUserData = $this->global->GetuserData(TdbShopArticleReview::INPUT_BASE_NAME);
}
$aDefaultFieldDataList = array('comment' => '', 'author_email' => '', 'author_name' => '', 'title' => '', 'send_comment_notification' => '0', 'rating' => 1);
if (isset($aPostUserData) && is_array($aPostUserData)) {
foreach ($aDefaultFieldDataList as $sDefaultFieldDataKey => $aDefaultFieldDataValue) {
if (!array_key_exists($sDefaultFieldDataKey, $aPostUserData)) {
$aPostUserData[$sDefaultFieldDataKey] = $aDefaultFieldDataValue;
}
}
$aDefaultFieldDataList = $aPostUserData;
}
return $aDefaultFieldDataList;
} | [
"protected",
"function",
"SetDefaultFieldVars",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"global",
"->",
"UserDataExists",
"(",
"TdbShopArticleReview",
"::",
"INPUT_BASE_NAME",
")",
")",
"{",
"$",
"aPostUserData",
"=",
"$",
"this",
"->",
"global",
"->",
... | Set default form parameter with init value or post values.
@return array | [
"Set",
"default",
"form",
"parameter",
"with",
"init",
"value",
"or",
"post",
"values",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php#L47-L63 | train |
chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php | MTPkgShopArticleReviewCore.AllowToCommentReview | protected function AllowToCommentReview()
{
if ($this->GetCommentTypeId()) {
$oModuleConfiguration = $this->GetModuleConfiguration();
if ($oModuleConfiguration->fieldAllowCommentReviews) {
return true;
}
}
return false;
} | php | protected function AllowToCommentReview()
{
if ($this->GetCommentTypeId()) {
$oModuleConfiguration = $this->GetModuleConfiguration();
if ($oModuleConfiguration->fieldAllowCommentReviews) {
return true;
}
}
return false;
} | [
"protected",
"function",
"AllowToCommentReview",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"GetCommentTypeId",
"(",
")",
")",
"{",
"$",
"oModuleConfiguration",
"=",
"$",
"this",
"->",
"GetModuleConfiguration",
"(",
")",
";",
"if",
"(",
"$",
"oModuleConfig... | Checks if its allowed to write a comment to a review.
Returns always false if package pkgcomment was not installed.
@return bool | [
"Checks",
"if",
"its",
"allowed",
"to",
"write",
"a",
"comment",
"to",
"a",
"review",
".",
"Returns",
"always",
"false",
"if",
"package",
"pkgcomment",
"was",
"not",
"installed",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php#L118-L128 | train |
chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php | MTPkgShopArticleReviewCore.GetCommentTypeId | protected function GetCommentTypeId()
{
if (false === $this->sPkgCommentTypeId) {
$sQuery = "SELECT * FROM `pkg_comment_type` WHERE `pkg_comment_type`.`class_name` = 'TPkgCommentTypePkgShopArticleReview'";
$oRes = MySqlLegacySupport::getInstance()->query($sQuery);
if (MySqlLegacySupport::getInstance()->num_rows($oRes) > 0) {
$aRow = MySqlLegacySupport::getInstance()->fetch_assoc($oRes);
$this->sPkgCommentTypeId = $aRow['id'];
} else {
$this->sPkgCommentTypeId = '';
}
}
return $this->sPkgCommentTypeId;
} | php | protected function GetCommentTypeId()
{
if (false === $this->sPkgCommentTypeId) {
$sQuery = "SELECT * FROM `pkg_comment_type` WHERE `pkg_comment_type`.`class_name` = 'TPkgCommentTypePkgShopArticleReview'";
$oRes = MySqlLegacySupport::getInstance()->query($sQuery);
if (MySqlLegacySupport::getInstance()->num_rows($oRes) > 0) {
$aRow = MySqlLegacySupport::getInstance()->fetch_assoc($oRes);
$this->sPkgCommentTypeId = $aRow['id'];
} else {
$this->sPkgCommentTypeId = '';
}
}
return $this->sPkgCommentTypeId;
} | [
"protected",
"function",
"GetCommentTypeId",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"sPkgCommentTypeId",
")",
"{",
"$",
"sQuery",
"=",
"\"SELECT * FROM `pkg_comment_type` WHERE `pkg_comment_type`.`class_name` = 'TPkgCommentTypePkgShopArticleReview'\"",
"... | Get the comment type for article reviews.
@return TdbPkgCommentType | [
"Get",
"the",
"comment",
"type",
"for",
"article",
"reviews",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php#L135-L149 | train |
chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php | MTPkgShopArticleReviewCore.AllowReadReview | protected function AllowReadReview()
{
$bAllowReadReview = false;
$oModuleConfiguration = $this->GetModuleConfiguration();
$oUser = TdbDataExtranetUser::GetInstance();
if ($oModuleConfiguration->fieldAllowShowReviewLoggedinUsersOnly && $oUser->IsLoggedIn() || !$oModuleConfiguration->fieldAllowShowReviewLoggedinUsersOnly) {
$bAllowReadReview = true;
}
return $bAllowReadReview;
} | php | protected function AllowReadReview()
{
$bAllowReadReview = false;
$oModuleConfiguration = $this->GetModuleConfiguration();
$oUser = TdbDataExtranetUser::GetInstance();
if ($oModuleConfiguration->fieldAllowShowReviewLoggedinUsersOnly && $oUser->IsLoggedIn() || !$oModuleConfiguration->fieldAllowShowReviewLoggedinUsersOnly) {
$bAllowReadReview = true;
}
return $bAllowReadReview;
} | [
"protected",
"function",
"AllowReadReview",
"(",
")",
"{",
"$",
"bAllowReadReview",
"=",
"false",
";",
"$",
"oModuleConfiguration",
"=",
"$",
"this",
"->",
"GetModuleConfiguration",
"(",
")",
";",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(... | Checks if its allowed to red reviews.
@return bool | [
"Checks",
"if",
"its",
"allowed",
"to",
"red",
"reviews",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php#L156-L166 | train |
chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php | MTPkgShopArticleReviewCore.AllowWriteReview | protected function AllowWriteReview()
{
$bAllowWriteReview = false;
$oModuleConfiguration = $this->GetModuleConfiguration();
$oUser = TdbDataExtranetUser::GetInstance();
if ($oModuleConfiguration->fieldAllowWriteReviewLoggedinUsersOnly && $oUser->IsLoggedIn() || !$oModuleConfiguration->fieldAllowWriteReviewLoggedinUsersOnly) {
$bAllowWriteReview = true;
}
return $bAllowWriteReview;
} | php | protected function AllowWriteReview()
{
$bAllowWriteReview = false;
$oModuleConfiguration = $this->GetModuleConfiguration();
$oUser = TdbDataExtranetUser::GetInstance();
if ($oModuleConfiguration->fieldAllowWriteReviewLoggedinUsersOnly && $oUser->IsLoggedIn() || !$oModuleConfiguration->fieldAllowWriteReviewLoggedinUsersOnly) {
$bAllowWriteReview = true;
}
return $bAllowWriteReview;
} | [
"protected",
"function",
"AllowWriteReview",
"(",
")",
"{",
"$",
"bAllowWriteReview",
"=",
"false",
";",
"$",
"oModuleConfiguration",
"=",
"$",
"this",
"->",
"GetModuleConfiguration",
"(",
")",
";",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
... | Checks if its allowed to write reviews.
@return bool | [
"Checks",
"if",
"its",
"allowed",
"to",
"write",
"reviews",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php#L173-L183 | train |
chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php | MTPkgShopArticleReviewCore.AllowRateReviews | protected function AllowRateReviews()
{
$bAllowRateReviews = $this->AllowReadReview();
if ($bAllowRateReviews) {
$oModuleConfiguration = $this->GetModuleConfiguration();
if (!$oModuleConfiguration->fieldAllowRateReview) {
$bAllowRateReviews = false;
}
}
return $bAllowRateReviews;
} | php | protected function AllowRateReviews()
{
$bAllowRateReviews = $this->AllowReadReview();
if ($bAllowRateReviews) {
$oModuleConfiguration = $this->GetModuleConfiguration();
if (!$oModuleConfiguration->fieldAllowRateReview) {
$bAllowRateReviews = false;
}
}
return $bAllowRateReviews;
} | [
"protected",
"function",
"AllowRateReviews",
"(",
")",
"{",
"$",
"bAllowRateReviews",
"=",
"$",
"this",
"->",
"AllowReadReview",
"(",
")",
";",
"if",
"(",
"$",
"bAllowRateReviews",
")",
"{",
"$",
"oModuleConfiguration",
"=",
"$",
"this",
"->",
"GetModuleConfig... | Checks if its allowed to rate reviews.
@return bool | [
"Checks",
"if",
"its",
"allowed",
"to",
"rate",
"reviews",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php#L190-L201 | train |
chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php | MTPkgShopArticleReviewCore.AllowReportReviews | protected function AllowReportReviews()
{
$bAllowRateReviews = $this->AllowReadReview();
if ($bAllowRateReviews) {
$oModuleConfiguration = $this->GetModuleConfiguration();
if (!$oModuleConfiguration->fieldAllowReportReviews) {
$bAllowRateReviews = false;
}
}
return $bAllowRateReviews;
} | php | protected function AllowReportReviews()
{
$bAllowRateReviews = $this->AllowReadReview();
if ($bAllowRateReviews) {
$oModuleConfiguration = $this->GetModuleConfiguration();
if (!$oModuleConfiguration->fieldAllowReportReviews) {
$bAllowRateReviews = false;
}
}
return $bAllowRateReviews;
} | [
"protected",
"function",
"AllowReportReviews",
"(",
")",
"{",
"$",
"bAllowRateReviews",
"=",
"$",
"this",
"->",
"AllowReadReview",
"(",
")",
";",
"if",
"(",
"$",
"bAllowRateReviews",
")",
"{",
"$",
"oModuleConfiguration",
"=",
"$",
"this",
"->",
"GetModuleConf... | Checks if its allowed to report reviews.
@return bool | [
"Checks",
"if",
"its",
"allowed",
"to",
"report",
"reviews",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php#L208-L219 | train |
chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php | MTPkgShopArticleReviewCore.NeedCaptcha | protected function NeedCaptcha()
{
$bNeedCaptcha = false;
$oUser = TdbDataExtranetUser::GetInstance();
$oModuleConfiguration = $this->GetModuleConfiguration();
if (!$oModuleConfiguration->fieldAllowWriteReviewLoggedinUsersOnly && !$oUser->IsLoggedIn()) {
$bNeedCaptcha = true;
}
return $bNeedCaptcha;
} | php | protected function NeedCaptcha()
{
$bNeedCaptcha = false;
$oUser = TdbDataExtranetUser::GetInstance();
$oModuleConfiguration = $this->GetModuleConfiguration();
if (!$oModuleConfiguration->fieldAllowWriteReviewLoggedinUsersOnly && !$oUser->IsLoggedIn()) {
$bNeedCaptcha = true;
}
return $bNeedCaptcha;
} | [
"protected",
"function",
"NeedCaptcha",
"(",
")",
"{",
"$",
"bNeedCaptcha",
"=",
"false",
";",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oModuleConfiguration",
"=",
"$",
"this",
"->",
"GetModuleConfiguration",
"(",
")"... | Check if captcha field is needed to show in forms.
@return bool | [
"Check",
"if",
"captcha",
"field",
"is",
"needed",
"to",
"show",
"in",
"forms",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php#L226-L236 | train |
chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php | MTPkgShopArticleReviewCore.GetModuleConfiguration | protected function GetModuleConfiguration()
{
if (is_null($this->oModuleConfiguration)) {
$oModuleConfiguration = TdbPkgShopArticleReviewModuleShopArticleReviewConfiguration::GetNewInstance();
if ($oModuleConfiguration->LoadFromField('cms_tpl_module_instance_id', $this->instanceID)) {
}
$this->oModuleConfiguration = $oModuleConfiguration;
}
return $this->oModuleConfiguration;
} | php | protected function GetModuleConfiguration()
{
if (is_null($this->oModuleConfiguration)) {
$oModuleConfiguration = TdbPkgShopArticleReviewModuleShopArticleReviewConfiguration::GetNewInstance();
if ($oModuleConfiguration->LoadFromField('cms_tpl_module_instance_id', $this->instanceID)) {
}
$this->oModuleConfiguration = $oModuleConfiguration;
}
return $this->oModuleConfiguration;
} | [
"protected",
"function",
"GetModuleConfiguration",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"oModuleConfiguration",
")",
")",
"{",
"$",
"oModuleConfiguration",
"=",
"TdbPkgShopArticleReviewModuleShopArticleReviewConfiguration",
"::",
"GetNewInstance",
... | Get the module config for the module instance.
@return TdbPkgShopArticleReviewModuleShopArticleReviewConfiguration | [
"Get",
"the",
"module",
"config",
"for",
"the",
"module",
"instance",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/WebModules/MTPkgShopArticleReviewCore/MTPkgShopArticleReviewCore.class.php#L243-L253 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.