Gets or finds the node and sets by id

@param int $id
@param bool $published
@return Node
162968
public function getOrFind($id, $published = true)
    {
        $node = $this->get($id);

        if (is_null($node))
        {
            $node = $published ?
                PublishedNode::find($id) :
                Node::find($id);

            $this->put($id, $node);
        }

        return $node;
    }
1185922
public function findOrFail($id, $columns = ['*'])
    {
        $this->parse();

        return $this->getHandler()->findOrFail($id, $this->getColumns($columns));
    }
1286695
public function getPageChildrenByidPage($id, $publishedOnly = 0)
	{
		$select = $this->tableGateway->getSql()->select();
		
		$select->columns(array('*'));
		
		$select->join('melis_cms_page_lang', 'melis_cms_page_lang.plang_page_id = melis_cms_page_tree.tree_page_id', 
						array('plang_lang_id'));
		$select->join('melis_cms_lang', 'melis_cms_lang.lang_cms_id = melis_cms_page_lang.plang_lang_id', 
						array('*'), $select::JOIN_LEFT);
		
		$select->join('melis_cms_page_published', 'melis_cms_page_published.page_id = melis_cms_page_tree.tree_page_id', 
						array('*'), $select::JOIN_LEFT);
		
		$select->join('melis_cms_page_style', 'melis_cms_page_tree.tree_page_id = melis_cms_page_style.pstyle_page_id', array(), $select::JOIN_LEFT);
		
		$select->join('melis_cms_style', ' melis_cms_style.style_id = melis_cms_page_style.pstyle_style_id', array('*'), $select::JOIN_LEFT);
		
		if ($publishedOnly == 1)
			$select->where('melis_cms_page_published.page_status=1');
		
		if ($publishedOnly == 0)
		{
    		$columns = $this->aliasColumnsFromTableDefinition('MelisEngine\MelisPageColumns', 's_');
		    $select->join('melis_cms_page_saved', 'melis_cms_page_saved.page_id = melis_cms_page_tree.tree_page_id',
					$columns, $select::JOIN_LEFT);
		}
		
		$select->join('melis_cms_page_seo', 'melis_cms_page_seo.pseo_id = melis_cms_page_tree.tree_page_id',
	       array('*'), $select::JOIN_LEFT);
		
		$select->join('melis_cms_page_default_urls', 'melis_cms_page_default_urls.purl_page_id = melis_cms_page_tree.tree_page_id',
	       array('*'), $select::JOIN_LEFT);
			
		$select->where('tree_father_page_id = ' . $id);
		$select->order('tree_page_order ASC');
		
		$resultSet = $this->tableGateway->selectWith($select);
		
		return $resultSet;
	}
685349
public function findById($id)
    {
        $post = get_post($id);
        if (!is_null($post)) {
            return self::getEntity($post);
        }
    }
397837
private function findNode($id)
    {
        $node = $this->get('clastic.node_manager')
            ->loadNode($id);

        if (!$node) {
            throw new NotFoundHttpException();
        }

        return $node;
    }
580795
public function getNodeAndSetLocale($name, $track = true, $published = true)
    {
        $node = $this->getNode($name, $track, $published);

        $locale = $node->getLocaleForNodeName($name);

        set_app_locale($locale);

        return $node;
    }
328361
public function getNewItem($id, $setID = true)
    {
        $class = $this->config()->get('tree_class');
        $object = Injector::inst()->create($class);
        if ($setID) {
            $object->ID = $id;
        }
        return $object;
    }
844203
public function findParentNodesByChildId($id)
	{
        // To be returned
        $result = array();

        $rl = $this->getRelations();
        $data = $rl[RelationBuilder::TREE_PARAM_ITEMS];

        // If can't find, then return empty array
        if (!isset($data[$id])) {
            return array();
        }

        $current = $data[$id];
        $parentId = $current[RelationBuilder::TREE_PARAM_PARENT_ID];

        while (isset($data[$parentId])) {
            $current = $data[$parentId];
            $parentId = $current[RelationBuilder::TREE_PARAM_PARENT_ID];

            array_push($result, $current);
        }

        return $result;
    }
1166077
public function findPages($unpublished = false)
    {
        $this->makeSelect();
        $this->sql .= " and collection_id is null";

        if (!$unpublished) {
            $this->sql .= " and published_date <= '{$this->today()}'";
        }

        return $this->find();
    }
87943
public function find($id, $columns = ['*'])
    {
        if (Uuid::validate($id)) {
            return $this->findByUuid($id, $columns);
        } else {
            return parent::find($id, $columns);
        }
    }
1008407
public function findDocument($id)
    {
        $documentPath = '/'.$this->databaseName.'/'.urlencode($id);

        return $this->httpClient->request('GET', $documentPath);
    }
1123507
public function getNodesByIds($ids, $published = true)
    {
        if (empty($ids))
        {
            return null;
        }

        if (is_string($ids))
        {
            $ids = json_decode($ids, true);
        }

        if (is_array($ids) && ! empty($ids))
        {
            $placeholders = implode(',', array_fill(0, count($ids), '?'));

            $nodes = Node::whereIn('id', $ids)
                ->orderByRaw('field(id,' . $placeholders . ')', $ids);

            if ($published)
            {
                $nodes->published();
            }

            $nodes = $nodes->get();

            return (count($nodes) > 0) ? $nodes : null;
        }

        return null;
    }
437970
public function findById($id)
    {
        foreach ($this->items as $page) {
            if ($page->getId() == $id) {
                return $page;
            } else if ($found = $page->getPages()->findById($id)) {
                return $found;
            }
        }
    }
959874
public static function node($id)
    {
        $id = intval($id);
        if (empty($id)) return null;
        
        if (!static::$caching || empty(static::$_nodes[$id])) {
            $result = static::findOne($id);
            if (static::$caching) {
                static::$_nodes[$id] = $result;
            } else {
                return $result;
            }
        }
        return static::$_nodes[$id];
    }
1333295
public function findOrNew($id, $columns = ['*'])
	{
		if (is_null($instance = $this->find($id, $columns))) {
			$instance = $this->getRelated()->newInstance();
		}

		return $instance;
	}
1296399
public function pub($id, $data)
    {
        if (!isset($this->events[$id])) {
            return false;
        }
        return $this->events[$id]->pub($data);
    }
330693
public function findChild($id)
    {
        foreach ($this->getChildren() as $child) {
            $result = $this->findChildInNode($child, $id);

            if ($result) {
                return $result;
            }
        }

        return null;
    }