/** * @param Comment $comment * @param Post $post * @param Guard $auth */ public function __construct(Comment $comment, Post $post, Guard $auth) { $this->comment = $comment; $this->config = objectify(config('blogify')); $this->post = $post; $this->auth = $auth; }
function apply($context, $args) { if ($this->boundContext !== null) { $context = $this->boundContext; if ($this->boundArgs) { $args = array_merge($this->boundArgs, $args); } } $this->args = $args; if (!$this->strict) { if ($context === null || $context === Object::$null) { $context = Object::$global; } else { if (!$context instanceof Object) { //primitives (boolean, number, string) should be wrapped in object $context = objectify($context); } } } $oldStackPosition = $this->callStackPosition; $oldArguments = $this->arguments; $oldContext = $this->context; $this->context = $context; $this->callStackPosition = self::$callStackLength; //add ourself to the call stack, execute, then remove self::$callStack[self::$callStackLength++] = $this; $result = call_user_func_array($this->fn, $args); self::$callStack[--self::$callStackLength] = null; $this->callStackPosition = $oldStackPosition; $this->arguments = $oldArguments; $this->context = $oldContext; return $result; }
/** * @param Post $post * @param Category $category * @param Tag $tag * @param DatabaseManager $db */ public function __construct(Post $post, Category $category, Tag $tag, DatabaseManager $db) { $this->post = $post; $this->category = $category; $this->tag = $tag; $this->db = $db; $this->config = objectify(config('blogify')); $this->middleware('jorenvanhocht\\Blogify\\Middleware\\ProtectedPost', ['only' => 'show']); }
/** * Return the object representation of the array received * * @param array to transform in object */ function objectify($array) { if (is_array($array)) { foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = objectify($value); } } } else { return $array; } return (object) $array; }
/** * @param \Illuminate\Contracts\Auth\Guard $auth */ public function __construct(Guard $auth) { $this->auth = $auth; $this->config = objectify(config('blogify')); $this->auth_user = $this->auth->check() ? $this->auth->user() : false; }
/** * Create a new command instance. * * @param \Illuminate\Contracts\Config\Repository $config * @param \Illuminate\Filesystem\Filesystem $filesystem */ public function __construct(Config $config, FileSystem $filesystem) { parent::__construct(); $this->config = objectify($config->get('createpackages')); $this->filesystem = $filesystem; }
/** * @param Object $obj * @param string $name * @return mixed * @throws Exception */ function call_method($obj, $name) { if ($obj === null || $obj === Object::$null) { throw new Ex(Error::create("Cannot read property '" . $name . "' of " . to_string($obj))); } $obj = objectify($obj); $fn = $obj->get($name); if (!$fn instanceof Func) { throw new Ex(Error::create(_typeof($fn) . " is not a function")); } $args = array_slice(func_get_args(), 2); return $fn->apply($obj, $args); }
public function __construct() { parent::__construct(); $this->config = objectify(config('blogify')); }
/** * Build a post object when there * is a cached post so we can put * the data back in the form * * @return object */ private function buildPostObject() { $hash = $this->auth_user->hash; $cached_post = $this->cache->get("autoSavedPost-{$hash}"); $post = []; $post['hash'] = ''; $post['title'] = $cached_post['title']; $post['slug'] = $cached_post['slug']; $post['content'] = $cached_post['content']; $post['publish_date'] = $cached_post['publishdate']; $post['status_id'] = $this->status->byHash($cached_post['status'])->id; $post['visibility_id'] = $this->visibility->byHash($cached_post['visibility'])->id; $post['reviewer_id'] = $this->user->byHash($cached_post['reviewer'])->id; $post['category_id'] = $this->category->byHash($cached_post['category'])->id; $post['tag'] = $this->buildTagsArrayForPostObject($cached_post['tags']); return objectify($post); }
public function email($value) { if (empty($value)) { throw new \InvalidArgumentException('Não é possível setar a propriedade "email" para um valor vazio.'); } $this->email = objectify($value); }
/** * Creates the global constructor used in user-land * @return Func */ static function getGlobalConstructor() { $Object = new Func(function ($value = null) { if ($value === null || $value === Object::$null) { return new Object(); } else { return objectify($value); } }); $Object->set('prototype', Object::$protoObject); $Object->setMethods(Object::$classMethods, true, false, true); return $Object; }
/** * @param $obj * @param null $key * @return bool * @throws Exception */ function _delete($obj, $key = null) { //don't allow deleting of variables, only properties if (func_num_args() === 1) { return false; } if ($obj === null || $obj === Object::$null) { throw new Ex(Error::create("Cannot convert undefined or null to object")); } $obj = objectify($obj); $obj->remove($key); return true; }
$p->num_thumbs = $num_thumbs; $fn = getTimeCheckFile($hash_tag, $sort_by, $num_thumbs); //echo '<pre>'; //print_r($fn); //exit; if ($fn['do_write']) { //$query = "SELECT A.*, B.username from posts A, members B, posts_comments C where A.active='1' AND A.USERID=B.USERID AND A.story like '%$p->hash_tag%' OR A.PID=C.PID AND C.comment like '%$p->hash_tag%' GROUP BY A.PID order by A.favclicks desc limit 0, $p->num_thumbs"; $query = "SELECT A.pid, A.story, A.pic, A.favclicks from posts A, members B, posts_comments C where A.active='1' AND A.USERID=B.USERID AND (A.story like '%{$p->hash_tag}%' OR (A.PID=C.PID AND C.comment like '%{$p->hash_tag}%')) GROUP BY A.PID order by {$order_by} limit 0, {$p->num_thumbs}"; $eq = $conn->Execute($query); if ($eq->recordcount() > 0) { $posts = $eq->getrows(); $obj = objectify($posts); if ($sort_by == 'random') { $posts2 = $posts; shuffle($posts2); $obj2 = objectify($posts2); } } else { $obj = "error: 'No data was returned by Minnano',"; } file_put_contents($fn['name'], $obj); unlink($fn['last_file']); if (isset($obj2)) { $obj = $obj2; } } else { $obj = file_get_contents($fn['name']); if ($sort_by === 'random') { $obj = jsonShuffle2(trim($obj)); } }
function jsonShuffle($json) { // "\r\n" breaks json_decode() $jack = array("post_dir:", "img_dir:", "data:", "pic:", "story:", "pid:", "\r\n"); $jill = array('"post_dir":', '"img_dir":', '"data":', '"pic":', '"story":', '"pid":', ""); $json = str_replace($jack, $jill, $json); $a = json_decode($json, true); $data = $a['data']; shuffle($data); return objectify($data); }