sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public static function camelize($string, $separator = null, $preserveWhiteSpace = false, $isKey = false)
{
empty($separator) && $separator = ['_', '-'];
$_newString = ucwords(str_replace($separator, ' ', $string));
if (false !== $isKey) {
$_newString = lcfirst($_newString);
... | Converts a separator delimited string to camel case
@param string $string
@param string $separator
@param boolean $preserveWhiteSpace
@param bool $isKey If true, first word is lower-cased
@return string | entailment |
public function handle()
{
$this->laravel['events']->fire('cache:clearing', ['file']);
$this->removeDirectory($this->cacheRoot);
$this->laravel['events']->fire('cache:cleared', ['file']);
$this->info('Cleared DreamFactory cache for all instances!');
} | Execute the console command.
@return mixed | entailment |
protected function removeDirectory($path)
{
$files = glob($path . '/*');
foreach ($files as $file) {
if (is_dir($file)) {
static::removeDirectory($file);
} else if (basename($file) !== '.gitignore') {
unlink($file);
}
}
... | Removes directories recursively.
@param $path | entailment |
public static function alert($type, $transKey, $transCount = 1, $transParameters = [])
{
$alerts = [];
if (Session::has('alerts')) {
$alerts = Session::get('alerts');
}
$message = trans_choice("forum::{$transKey}", $transCount, $transParameters);
array_push($ale... | Process an alert message to display to the user.
@param string $type
@param string $transKey
@param string $transCount
@return void | entailment |
public static function route($route, $model = null)
{
if (!starts_with($route, config('forum.routing.as'))) {
$route = config('forum.routing.as') . $route;
}
$params = [];
$append = '';
if ($model) {
switch (true) {
case $model instan... | Generate a URL to a named forum route.
@param string $route
@param null|\Illuminate\Database\Eloquent\Model $model
@return string | entailment |
public static function routes(Router $router)
{
$controllers = config('forum.frontend.controllers');
// Forum index
$router->get('/', ['as' => 'index', 'uses' => "{$controllers['category']}@index"]);
// New/updated threads
$router->get('new', ['as' => 'index-new', 'uses' =>... | Register the standard forum routes.
@param Router $router
@return void | entailment |
public function handle()
{
/** @var RestHandler $service */
$service = ServiceManager::getService($this->service);
/** @var \DreamFactory\Core\Contracts\ServiceResponseInterface $rs */
$rs = ServiceManager::handleRequest(
$service->getName(),
Verbs::POST, '_ta... | Execute the job. | entailment |
public function index($version = null)
{
try {
$request = new ServiceRequest();
if (!empty($version)) {
$request->setApiVersion($version);
}
Log::info('[REQUEST]', [
'API Version' => $request->getApiVersion(),
'... | Handles the root (/) path
@param null|string $version
@return null|ServiceResponseInterface|Response
@throws \DreamFactory\Core\Exceptions\NotImplementedException | entailment |
public function handleVersionedService($version, $service, $resource = null)
{
$request = new ServiceRequest();
$request->setApiVersion($version);
return $this->handleServiceRequest($request, $service, $resource);
} | Handles all service requests
@param null|string $version
@param string $service
@param null|string $resource
@return ServiceResponseInterface|Response|null
@throws \DreamFactory\Core\Exceptions\NotImplementedException | entailment |
public function handleService($service, $resource = null)
{
$request = new ServiceRequest();
return $this->handleServiceRequest($request, $service, $resource);
} | Handles all service requests
@param string $service
@param null|string $resource
@return ServiceResponseInterface|Response|null
@throws \DreamFactory\Core\Exceptions\NotImplementedException | entailment |
public function up()
{
if (Schema::hasTable('service_type')) {
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
$output->writeln('Scanning database for old sql_db service type...');
$ids = DB::table('service')->where('type', 'sql_db')->pluck('id');
... | Run the migrations.
@return void | entailment |
public function getService()
{
if (!empty($this->service)) {
return $this->service;
}
$service = '';
$uri = trim($this->getRequestUri(), '/');
if (!empty($uri)) {
$uriParts = explode('/', $uri);
// Need to get the 3rd element of the array ... | {@inheritdoc} | entailment |
public function getResource()
{
if (!empty($this->service)) {
return $this->service;
}
$resource = '';
$uri = trim($this->getRequestUri(), '/');
if (!empty($uri)) {
$uriParts = explode('/', $uri);
// Need to get all elements after the 3rd ... | {@inheritdoc} | entailment |
public function getParameter($key = null, $default = null)
{
if ($this->parameters) {
if (null === $key) {
return $this->parameters;
} else {
return array_get($this->parameters, $key, $default);
}
}
return Request::query($k... | {@inheritdoc} | entailment |
public function getPayloadData($key = null, $default = null)
{
if (!empty($this->contentAsArray)) {
if (null === $key) {
return $this->contentAsArray;
} else {
return array_get($this->contentAsArray, $key, $default);
}
}
//... | @param null $key
@param null $default
@return array
@throws BadRequestException
@throws \DreamFactory\Core\Exceptions\NotImplementedException | entailment |
protected function csv($key = null, $default = null)
{
if (empty($this->contentAsArray)) {
$content = $this->getContent();
$data = DataFormatter::csvToArray($content);
if (!empty($data)) {
$this->contentAsArray = ResourcesWrapper::wrapResources($data);
... | Returns CSV payload data
@param null $key
@param null $default
@return array|mixed|null | entailment |
protected function xml($key = null, $default = null)
{
if (empty($this->contentAsArray)) {
$content = $this->getContent();
$data = DataFormatter::xmlToArray($content);
if (!empty($data)) {
if ((1 === count($data)) && !array_key_exists(ResourcesWrapper::ge... | Returns XML payload data.
@param null $key
@param null $default
@return array|mixed|null | entailment |
protected function json($key = null, $default = null)
{
if (null === $key) {
return Request::json()->all();
} else {
return Request::json($key, $default);
}
} | @param null $key
@param null $default
@return mixed | entailment |
public function getHeader($key = null, $default = null)
{
if (null === $key) {
return $this->getHeaders();
}
if ($this->headers) {
return array_get($this->headers, $key, $default);
}
return Request::header($key, $default);
} | {@inheritdoc} | entailment |
public function getHeaders()
{
if ($this->headers) {
return $this->headers;
}
return array_map(
function ($value){
return (is_array($value)) ? implode(',', $value) : $value;
},
Request::header()
);
} | {@inheritdoc} | entailment |
public function getFile($key = null, $default = null)
{
if (null === $key) {
$files = [];
foreach ($_FILES as $key => $FILE){
$files[$key] = $this->formatFileInfo($FILE);
}
return $files;
} else {
$file = array_get($_FILES, ... | @param null $key
@param null $default
@return array|mixed | entailment |
protected function formatFileInfo($fileInfo)
{
if(empty($fileInfo) || !is_array($fileInfo) || isset($fileInfo[0])){
return $fileInfo;
}
$file = [];
foreach ($fileInfo as $key => $value){
if(is_array($value)){
foreach ($value as $k => $v){
... | Format file data for ease of use
@param array|null $fileInfo
@return array | entailment |
public function getApiKey()
{
if (!empty($this->parameters) && !empty($this->headers)) {
$apiKey = $this->getParameter('api_key');
if (empty($apiKey)) {
$apiKey = $this->getHeader('X_DREAMFACTORY_API_KEY');
}
} else {
$apiKey = Request:... | {@inheritdoc} | entailment |
public function setBounds($from, $length = null, $stopOutOfBounds = false) {
$this->from = $from;
$this->length = $length;
$this->outOfBounds = (bool) $stopOutOfBounds;
return $this;
} | Set valid bounds (rows which will be printer)
@param int $from from row index...
@param int $length number of rows to print
@return Debug | entailment |
public function configure(TcTable $table) {
$table
->on(TcTable::EV_COLUMN_ADDED, [$this, 'columnAdded'])
->on(TcTable::EV_BODY_ADD, [$this, 'bodyAdd'])
->on(TcTable::EV_BODY_ADDED, [$this, 'bodyAdded'])
->on(TcTable::EV_BODY_SKIPPED, [$this, 'bodySkipped'])
... | {@inheritDocs} | entailment |
private function inBounds() {
$in = true;
if ($this->from !== null) {
$in = $this->current >= $this->from;
if ($in && $this->length !== null) {
$in = $this->current < $this->from + $this->length;
if (!$in && $this->outOfBounds) {
... | Check if the current row is in debug bounds
@return bool | entailment |
private function listenTo($event = null) {
if ($event === null && $this->getEventInvoker()) {
$event = $this->getEventInvoker()['id'];
}
return !$this->listen || in_array($event, $this->listen);
} | Check if the given event is listenable
@param int $event event id, current event if null
@return bool | entailment |
public function getModel($table)
{
if (isset($this->map[$table])) {
return $this->map[$table];
}
return null;
} | Return the model for the given table.
@param string $table
@return string | entailment |
public function getTable($model)
{
if (false !== $pos = array_search($model, $this->map)) {
return $pos;
}
return null;
} | Return the table for the given model.
@param string $model
@return string | entailment |
public static function getConfig($id, $local_config = null, $protect = true)
{
$config = parent::getConfig($id, $local_config, $protect);
if ($cacheConfig = ServiceCacheConfig::whereServiceId($id)->first()) {
$config = array_merge($config, $cacheConfig->toArray());
}
ret... | {@inheritdoc} | entailment |
public static function setConfig($id, $config, $local_config = null)
{
ServiceCacheConfig::setConfig($id, $config, $local_config);
return parent::setConfig($id, $config, $local_config);
} | {@inheritdoc} | entailment |
public static function storeConfig($id, $config)
{
ServiceCacheConfig::storeConfig($id, $config);
return parent::storeConfig($id, $config);
} | {@inheritdoc} | entailment |
public function indexNew()
{
$threads = $this->api('thread.index-new')->get();
event(new UserViewingNew($threads));
return view('forum::thread.index-new', compact('threads'));
} | GET: Return a new/updated threads view.
@return \Illuminate\Http\Response | entailment |
public function markNew(Request $request)
{
$threads = $this->api('thread.mark-new')->parameters($request->only('category_id'))->patch();
event(new UserMarkingNew);
if ($request->has('category_id')) {
$category = $this->api('category.fetch', $request->input('category_id'))->get... | PATCH: Mark new/updated threads as read for the current user.
@param Request $request
@return \Illuminate\Http\Response | entailment |
public function show(Request $request)
{
$thread = $this->api('thread.fetch', $request->route('thread'))
->parameters(['include_deleted' => auth()->check()])
->get();
event(new UserViewingThread($thread));
$category = $thread->category;
... | GET: Return a thread view.
@param Request $request
@return \Illuminate\Http\Response | entailment |
public function create(Request $request)
{
$category = $this->api('category.fetch', $request->route('category'))->get();
if (!$category->threadsEnabled) {
Forum::alert('warning', 'categories.threads_disabled');
return redirect(Forum::route('category.show', $category));
... | GET: Return a 'create thread' view.
@param Request $request
@return \Illuminate\Http\Response | entailment |
public function store(Request $request)
{
$category = $this->api('category.fetch', $request->route('category'))->get();
if (!$category->threadsEnabled) {
Forum::alert('warning', 'categories.threads_disabled');
return redirect(Forum::route('category.show', $category));
... | POST: Store a new thread.
@param Request $request
@return \Illuminate\Http\RedirectResponse | entailment |
public function update(Request $request)
{
$action = $request->input('action');
$thread = $this->api("thread.{$action}", $request->route('thread'))->parameters($request->all())->patch();
Forum::alert('success', 'threads.updated', 1);
return redirect(Forum::route('thread.show', $th... | PATCH: Update a thread.
@param Request $request
@return \Illuminate\Http\RedirectResponse | entailment |
public function destroy(Request $request)
{
$this->validate($request, ['action' => 'in:delete,permadelete']);
$permanent = !config('forum.preferences.soft_deletes') || ($request->input('action') == 'permadelete');
$parameters = $request->all();
$parameters['force'] = $permanent ? 1... | DELETE: Delete a thread.
@param Request $request
@return \Illuminate\Http\RedirectResponse | entailment |
public function configure(array $settings = [])
{
if (empty($this->commandName = array_get($settings, 'command_name'))) {
throw new \Exception("Invalid configuration: missing command name.");
}
// Various ways to figure out how to run this thing
// check settings, then g... | @param array $settings
@throws \Exception | entailment |
public static function getApiKey($request)
{
// Check for API key in request parameters.
$apiKey = $request->query('api_key');
if (empty($apiKey)) {
// Check for API key in request HEADER.
$apiKey = $request->header('X_DREAMFACTORY_API_KEY');
}
if (emp... | @param Request $request
@return mixed | entailment |
public static function getJwt($request)
{
$token = static::getJWTFromAuthHeader();
if (empty($token)) {
$token = $request->header('X_DREAMFACTORY_SESSION_TOKEN');
}
if (empty($token)) {
$token = $request->input('session_token');
}
return $toke... | @param Request $request
@return mixed | entailment |
protected static function getJWTFromAuthHeader()
{
if ('testing' === env('APP_ENV')) {
// getallheaders method is not available in unit test mode.
return [];
}
if (!function_exists('getallheaders')) {
function getallheaders()
{
... | Gets the token from Authorization header.
@return string | entailment |
public static function getScriptToken($request)
{
// Check for script authorizing token in request parameters.
$token = $request->query('script_token');
if (empty($token)) {
// Check for script token in request HEADER.
$token = $request->header('X_DREAMFACTORY_SCRIPT_... | @param Request $request
@return mixed | entailment |
public function handle(Request $request, \Closure $next)
{
// Not using any stateful session. Therefore, no need to track session
// using cookies. Disabling tracking session by browser cookies.
ini_set('session.use_cookies', 0);
if (!in_array($route = $request->getPathInfo(), ['/set... | @param Request $request
@param \Closure $next
@return array|mixed|string | entailment |
public function boot()
{
// add our df config
$configPath = __DIR__ . '/../config/df.php';
if (function_exists('config_path')) {
$publishPath = config_path('df.php');
} else {
$publishPath = base_path('config/df.php');
}
$this->publishes([$conf... | Bootstrap the application events. | entailment |
protected function addMiddleware()
{
// the method name was changed in Laravel 5.4
if (method_exists(\Illuminate\Routing\Router::class, 'aliasMiddleware')) {
Route::aliasMiddleware('df.auth_check', AuthCheck::class);
Route::aliasMiddleware('df.access_check', AccessCheck::clas... | Register any middleware aliases.
@return void | entailment |
protected function encryptAttribute($key, &$value)
{
if (!is_null($value) && in_array($key, $this->getEncryptable())) {
$value = Crypt::encrypt($value);
return true;
}
return false;
} | Check if the attribute is marked encrypted, if so return the decrypted value.
@param string $key Attribute name
@param mixed $value Value of the attribute $key, decrypt if encrypted
@return bool Whether or not the attribute is being decrypted | entailment |
protected function decryptAttribute($key, &$value)
{
if (!is_null($value) && !$this->encryptedView && in_array($key, $this->getEncryptable())) {
$value = Crypt::decrypt($value);
return true;
}
return false;
} | Check if the attribute is marked encrypted, if so return the decrypted value.
@param string $key Attribute name
@param mixed $value Value of the attribute $key, decrypt if encrypted
@return bool Whether or not the attribute is being decrypted | entailment |
protected function addDecryptedAttributesToArray(array $attributes)
{
if (!$this->encryptedView) {
foreach ($this->getEncryptable() as $key) {
if (!array_key_exists($key, $attributes)) {
continue;
}
if (!empty($attributes[$key]... | Decrypt encryptable attributes found in outgoing array
@param array $attributes
@return array | entailment |
public static function toNumeric($contentType)
{
if (!is_string($contentType)) {
throw new \InvalidArgumentException('The content type "' . $contentType . '" is not a string.');
}
return static::defines(strtoupper($contentType), true);
} | @param string $contentType
@throws NotImplementedException
@return string | entailment |
public static function toString($numericLevel = self::TEXT)
{
if (!is_numeric($numericLevel)) {
throw new \InvalidArgumentException('The content type "' . $numericLevel . '" is not numeric.');
}
return static::nameOf($numericLevel, true, false);
} | @param int $numericLevel
@throws NotImplementedException
@return string | entailment |
public function configure(TcTable $table) {
$table
->on(TcTable::EV_BODY_ADD, [$this, 'resetFill'])
->on(TcTable::EV_ROW_ADD, [$this, 'setFill']);
} | {@inheritDocs} | entailment |
public function setFill(TcTable $table) {
if ($this->disabled) {
$fill = false;
} else {
$fill = $this->rowCurrentStripe = !$this->rowCurrentStripe;
}
foreach ($table->getRowDefinition() as $column => $row) {
$table->setRowDefinition($column, 'fill', $... | Set the background of the row
@param TcTable $table
@return void | entailment |
public function moveY(TcTable $table) {
$y = 0.6 / $table->getPdf()->getScaleFactor();
$table->getPdf()->SetY($table->getPdf()->GetY() + $y);
} | Adjust Y because cell background passes over the previous cell's border,
hiding it.
@param TcTable $table | entailment |
public static function getParentFolder($path)
{
$path = rtrim($path, '/'); // may be a folder
$marker = strrpos($path, '/');
if (false === $marker) {
return '';
}
return substr($path, 0, $marker);
} | @param $path
@return string | entailment |
public static function getNameFromPath($path)
{
$path = rtrim($path, '/'); // may be a folder
if (empty($path)) {
return '.';
} // self directory
$marker = strrpos($path, '/');
if (false === $marker) {
return $path;
}
return substr($p... | @param $path
@return string | entailment |
public static function url_exist($url)
{
$headers = @get_headers($url);
if (empty($headers) || 'HTTP/1.1 404 Not Found' == $headers[0]) {
return false;
}
return true;
} | @param string $url
@return bool | entailment |
public static function importUrlFileToTemp($url, $name = '')
{
if (static::url_exist($url)) {
$readFrom = @fopen($url, 'rb');
if ($readFrom) {
$directory = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
// $ext = FileUtilities::getFileExtensi... | @param string $url
@param string $name name of the temporary file to create
@throws NotFoundException
@throws \Exception
@return string temporary file path | entailment |
public static function determineContentType($ext = '', $content = '', $local_file = '', $default = '')
{
/**
* @var array of file extensions to mime types
*/
static $mimeTypes = array(
'123' => 'application/vnd.lotus-1-2-3',
'3dml' => 'text/vn... | @param string $ext
@param string $content
@param string $local_file
@param string $default
@return string | entailment |
public static function deleteTree($dir, $force = false, $delete_self = true)
{
if (is_dir($dir)) {
$files = array_diff(scandir($dir), array('.', '..'));
if (!empty($files) && !$force) {
throw new \Exception("Directory not empty, can not delete without force option.");... | @param $dir
@param bool $force
@param bool $delete_self
@throws \Exception | entailment |
public static function copyTree($src, $dst, $clean = false, $skip = array('.', '..'))
{
if (file_exists($dst) && $clean) {
static::deleteTree($dst);
}
if (is_dir($src)) {
@mkdir($dst);
$files = array_diff(scandir($src), $skip);
foreach ($files ... | @param string $src
@param string $dst
@param bool $clean
@param array $skip
@return void | entailment |
public static function addTreeToZip($zip, $root, $path = '', $skip = array('.', '..'))
{
$dirPath = rtrim($root, '/') . DIRECTORY_SEPARATOR;
if (!empty($path)) {
$dirPath .= $path . DIRECTORY_SEPARATOR;
}
if (is_dir($dirPath)) {
$files = array_diff(scandir($di... | @param \ZipArchive $zip
@param string $root
@param string $path
@param array $skip
@throws \Exception | entailment |
public static function rearrangePostedFiles($arr)
{
$new = array();
foreach ($arr as $key => $all) {
if (is_array($all)) {
foreach ($all as $i => $val) {
$new[$i][$key] = $val;
}
} else {
$new[0][$key] = $all... | @param $arr
@return array | entailment |
public static function updateEnvSetting(array $settings, $path = null)
{
if (empty($path)) {
$path = base_path('.env');
}
if (file_exists($path)) {
$subject = file_get_contents($path);
foreach ($settings as $key => $value) {
// Uncomment ... | Updates .env file setting.
@param array $settings
@param null $path | entailment |
public function addColumn(ColumnSchema $schema)
{
$key = strtolower($schema->name);
$this->columns[$key] = $schema;
} | Sets the named column metadata.
@param ColumnSchema $schema | entailment |
public function getColumn($name, $use_alias = false)
{
if ($use_alias) {
foreach ($this->columns as $column) {
if (0 === strcasecmp($name, $column->getName($use_alias))) {
return $column;
}
}
} else {
$key = strt... | Gets the named column metadata.
@param string $name column name
@param bool $use_alias
@return ColumnSchema metadata of the named column. Null if the named column does not exist. | entailment |
public function getColumnNames($use_alias = false)
{
$columns = [];
/** @var ColumnSchema $column */
foreach ($this->columns as $column) {
$columns[] = $column->getName($use_alias);
}
return $columns;
} | @param bool $use_alias
@return array list of column names | entailment |
public function getColumns($use_alias = false)
{
if ($use_alias) {
// re-index for alias usage, easier to find requested fields from client
$columns = [];
/** @var ColumnSchema $column */
foreach ($this->columns as $column) {
$columns[strtolowe... | @param bool $use_alias
@return ColumnSchema[] | entailment |
public function getRelation($name, $use_alias = false)
{
if ($use_alias) {
foreach ($this->relations as $relation) {
if (0 === strcasecmp($name, $relation->getName($use_alias))) {
return $relation;
}
}
} else {
$... | Gets the named relation metadata.
@param string $name relation name
@param bool $use_alias
@return RelationSchema metadata of the named relation. Null if the named relation does not exist. | entailment |
public function getRelationNames($use_alias = false)
{
$relations = [];
foreach ($this->relations as $relation) {
$relations[] = $relation->getName($use_alias);
}
return $relations;
} | @param bool $use_alias
@return array list of column names | entailment |
public function getRelations($use_alias = false)
{
if ($use_alias) {
// re-index for alias usage, easier to find requested fields from client
$relations = [];
/** @var RelationSchema $column */
foreach ($this->relations as $column) {
$relations... | @param bool $use_alias
@return RelationSchema[] | entailment |
protected function isProtectedAttribute($key, $value)
{
return (in_array($key, $this->getProtectable()) && ($value === $this->protectionMask));
} | Check if the attribute coming from client is set to mask. If so, skip writing to database.
@param string $key Attribute name
@param mixed $value Value of the attribute $key
@return bool | entailment |
protected function protectAttribute($key, &$value)
{
if (!is_null($value) && $this->protectedView && in_array($key, $this->getProtectable())) {
$value = $this->protectionMask;
return true;
}
return false;
} | Check if the attribute is marked protected, if so return the mask, not the value.
@param string $key Attribute name
@param mixed $value Value of the attribute $key, updated to mask if protected
@return bool Whether or not the attribute is being protected | entailment |
protected function addProtectedAttributesToArray(array $attributes)
{
if ($this->protectedView) {
foreach ($this->getProtectable() as $key) {
if (isset($attributes[$key])) {
$attributes[$key] = $this->protectionMask;
}
}
}
... | Replace all protected attributes in the given array with the mask
@param array $attributes
@return array | entailment |
public function handleRequest(ServiceRequestInterface $request, $resource = null)
{
Log::info('[REQUEST]', [
'API Version' => $request->getApiVersion(),
'Method' => $request->getMethod(),
'Service' => $this->name,
'Resource' => $resource,
... | {@inheritdoc} | entailment |
public function checkPermission($operation, $resource = null)
{
$requestType = ($this->request) ? $this->request->getRequestorType() : ServiceRequestorTypes::API;
Session::checkServicePermission($operation, $this->name, $resource, $requestType);
} | {@inheritdoc} | entailment |
public function getPermissions($resource = null)
{
$requestType = ($this->request) ? $this->request->getRequestorType() : ServiceRequestorTypes::API;
return Session::getServicePermissions($this->name, $resource, $requestType);
} | {@inheritdoc} | entailment |
protected function handleGET()
{
if ($this->request->getParameterAsBool(ApiOptions::AS_ACCESS_LIST)) {
return ResourcesWrapper::wrapResources($this->getAccessList());
}
return parent::handleGET();
} | {@inheritdoc} | entailment |
protected function parseSwaggerEvents(array $content, array $access = [])
{
$events = [];
$eventCount = 0;
foreach (array_get($content, 'paths', []) as $path => $api) {
$apiEvents = [];
$apiParameters = [];
$pathParameters = [];
$path = trim(... | @param array $content
@param array $access
@return array | entailment |
public function getAttributeValue($key)
{
$value = $this->getAttributeValueBase($key);
$this->protectAttribute($key, $value);
return $value;
} | {@inheritdoc} | entailment |
protected function getAttributeFromArray($key)
{
$value = $this->getAttributeFromArrayBase($key);
$this->decryptAttribute($key, $value);
return $value;
} | {@inheritdoc} | entailment |
public function setAttribute($key, $value)
{
// if protected, and trying to set the mask, throw it away
if ($this->isProtectedAttribute($key, $value)) {
return $this;
}
$return = $this->setAttributeBase($key, $value);
$value = $this->attributes[$key];
$t... | {@inheritdoc} | entailment |
public function attributesToArray()
{
$attributes = $this->attributesToArrayBase();
$attributes = $this->addDecryptedAttributesToArray($attributes);
$attributes = $this->addProtectedAttributesToArray($attributes);
return $attributes;
} | {@inheritdoc} | entailment |
public static function validateAsArray($data, $str_delimiter = null, $check_single = false, $on_fail = null)
{
if (is_string($data) && ('' !== $data) && (is_string($str_delimiter) && !empty($str_delimiter))) {
$data = array_map('trim', explode($str_delimiter, trim($data, $str_delimiter)));
... | @param array | string $data Array to check or comma-delimited string to convert
@param string | null $str_delimiter Delimiter to check for string to array mapping, no op if null
@param boolean $check_single Check if single (associative) needs to be made multiple (numeric)
@param string | null $on_fai... | entailment |
public function validator(array $data)
{
$validationRules = [
'name' => 'required|max:255',
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email|max:255|unique:user',
'username' => 'min:6|unique:user,usern... | Get a validator for an incoming registration request.
@param array $data
@return \Illuminate\Contracts\Validation\Validator | entailment |
public function create(array $data, $serviceId = null)
{
/** @var \DreamFactory\Core\User\Services\User $userService */
$userService = ServiceManager::getService('user');
if (!$userService->allowOpenRegistration) {
throw new ForbiddenException('Open Registration is not enabled.')... | Creates a non-admin user.
@param array $data
@param integer $serviceId
@return \DreamFactory\Core\Models\User
@throws \DreamFactory\Core\Exceptions\ForbiddenException
@throws \DreamFactory\Core\Exceptions\InternalServerErrorException
@throws \Exception | entailment |
protected static function sendConfirmation($user, $emailServiceId, $emailTemplateId, $deleteOnError = true)
{
try {
if (empty($emailServiceId)) {
throw new InternalServerErrorException('No email service configured for user invite. See system configuration.');
}
... | @param $user User
@param $emailServiceId
@param $emailTemplateId
@param bool|true $deleteOnError
@throws \DreamFactory\Core\Exceptions\InternalServerErrorException | entailment |
public static function generateConfirmationCode($length = 32)
{
$length = ($length < 5) ? 5 : (($length > 32) ? 32 : $length);
$range = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$code = '';
for ($i = 0; $i < $length; $i++) {
$code .= $range[rand(0, strlen($range) - 1)];
... | Generates a user confirmation code. (min 5 char)
@param int $length
@return string | entailment |
public function getLink($rel)
{
$link = self::findByRel($this->links, $rel);
if (!$link) {
throw new RelNotFoundException($rel, array_keys($this->links));
}
if (is_array($link)) {
throw new LinkNotUniqueException();
}
... | {@inheritDoc} | entailment |
public function getLinks($rel)
{
$links = self::findByRel($this->links, $rel);
if (!$links) {
throw new RelNotFoundException($rel, array_keys($this->links));
}
if (!is_array($links)) {
throw new LinkUniqueException();
}
... | {@inheritDoc} | entailment |
public function getEmbeddedResource($rel)
{
$resource = self::findByRel($this->embeddedResources, $rel);
if (!$resource) {
throw new RelNotFoundException($rel, array_keys($this->embeddedResources));
}
if (is_array($resource)) {
throw new Embe... | {@inheritDoc} | entailment |
public function getEmbeddedResources($rel)
{
$resources = self::findByRel($this->embeddedResources, $rel);
if (!$resources) {
throw new RelNotFoundException($rel, array_keys($this->embeddedResources));
}
if (!is_array($resources)) {
throw new... | {@inheritDoc} | entailment |
private static function findByRel(array $a, $rel)
{
$relName = mb_strtolower($rel, 'UTF-8');
foreach ($a as $name => $value) {
if (mb_strtolower($name, 'UTF-8') === $relName) {
return $value;
}
}
return null;
} | Looks for the given relation name in a case-insensitive
fashion and returns the corresponding value.
@return mixed The value in $a matching the relation name
or null if not found. | entailment |
public static function fromJson($json)
{
if (!$json) {
$json = [];
}
if (!is_array($json)) {
if (is_object($json)) {
$json = (array) $json;
} elseif (is_string($json)) {
$json = json_decode(trim($json) ? $json : '{}... | {@inheritDoc} | entailment |
public static function registerUser($user, array $payload = [])
{
$source = 'Product Install DreamFactory';
if (env('DF_MANAGED', false)) {
$serverName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
if (false === strpos($serverName, '.enterprise.dreamfactory... | @param User $user
@param array $payload
@return bool | entailment |
protected static function cleanResult(
$response,
/** @noinspection PhpUnusedParameterInspection */
$fields
) {
// for collections and models
if (is_object($response) && method_exists($response, 'toArray')) {
return $response->toArray();
}
return ... | If fields is not '*' (all) then clean out any unwanted properties.
@param mixed $response
@param mixed $fields
@return array | entailment |
public static function bulkCreate(array $records, array $params = [])
{
if (empty($records)) {
throw new BadRequestException('There are no record sets in the request.');
}
$response = [];
$errors = false;
$rollback = array_get_bool($params, ApiOptions::ROLLBACK);... | @param $records
@param array $params
@return array|mixed
@throws BadRequestException
@throws \Exception | entailment |
public static function createById($id, $record, $params = [])
{
$m = new static;
$pk = $m->getPrimaryKey();
$record[$pk] = $id;
try {
$response = static::bulkCreate([$record], $params);
return current($response);
} catch (BatchException $ex) {
... | @param $id
@param $record
@param array $params
@return array|mixed
@throws \DreamFactory\Core\Exceptions\BadRequestException
@throws \Exception | entailment |
public function update(array $attributes = [], array $options = [])
{
$relations = [];
$transaction = false;
foreach ($attributes as $key => $value) {
if ($this->isRelationMapped($key)) {
$relations[$key] = $value;
unset($attributes[$key]);
... | Update the model in the database.
@param array $attributes
@param array $options
@return bool|int
@throws \Exception | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.