Returns an attribute by id/code

@param   string  $id
@param   bool    $create     Whether or not to create an instance on the fly if it doesn't yet exists

@return RemoteAttributeInterface|null
490465
public function getAttribute($id, $create = false)
    {
        foreach ($this->attributes as $attribute) {
            if ($id == $attribute->getId()) {
                return $attribute;
            }
        }

        if ($create) {
            $attribute = new Attribute();
            $attribute->setId($id);
            $this->addAttribute($attribute);

            return $attribute;
        }

        return null;
    }
165470
public static function getByIdType($id, $type)
    {
        $o = self::factory($type);
		$o->load($id);
        return $o;
    }
348917
public function get($id)
    {
        //ACCESS CHECK
        if (!$this->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }

        // get default site data - kinda hacky, but keeps us to one controller
        if ($id == 'default') {
            $siteManager = $this->getSiteManager();

            $data = $siteManager->getDefaultSiteValues();

            $site = new Site(
                $this->getCurrentUserId(),
                'Get default site values in ' . get_class($this)
            );

            $site->populate($data);

            return new ApiJsonModel($site, 0, 'Success');
        }

        // get current site data - kinda hacky, but keeps us to one controller
        if ($id == 'current') {
            $site = $this->getCurrentSite();

            return new ApiJsonModel($site, 0, 'Success');
        }

        /** @var \Rcm\Repository\Site $siteRepo */
        $siteRepo = $this->getEntityManager()->getRepository(
            \Rcm\Entity\Site::class
        );

        try {
            $site = $siteRepo->find($id);
        } catch (\Exception $e) {
            return new ApiJsonModel(
                null,
                1,
                "Failed to find site by id ({$id})"
            );
        }
        /* ADDED THIS CHECK TO GET RID OF ERROR. */
        /* NOT SURE WHY TRY CATCH ABOVE ISN'T WORKING */

        if ($site instanceof Site) {
            return new ApiJsonModel($site, 0, 'Success');
        } else {
            return new ApiJsonModel(null, 1, "Failed to find site by id ({$id})");
        }
    }
747140
public function create(bool $returnID = false, bool $pull_force = false)
    {
        $url = self::$base_url.'/'.__FUNCTION__.'?'.http_build_query(['name' => $this->container_name]);

        $this->setCreateJson(null);

        $this->docker_image->pull($this->image, 'latest', $pull_force);

        $json = self::$curl->post($url, $this->getCreateJson(), self::$header);

        $id = json_decode($json)->Id ?? null;

        if (null === $id) {
            throw new Exception(json_decode($json)->message ?? $json, self::$curl->getCode());
        }

        $this->container_id = $id;

        $this->container_name = null;
        $this->cleanupConfig();

        if ($returnID) {
            return $id;
        }

        return $this;
    }
171686
private function getService($id)
    {
        if (null !== $this->container && $this->container->has($id)) {
            return $this->container->get($id);
        }

        return null;
    }
493181
public function get(string $id)
    {
        $app = App::get();
        $data = $app->data->getValue('bearcms/addons/addon/' . md5($id) . '.json');
        if ($data !== null) {
            return $this->makeAddonFromRawData($data);
        }
        return null;
    }
952750
public function getById($id)
    {
        $modelResult = $this->getRequest()->request(
            'GET',
            $this->getRequestUrl(sprintf('models/%s', $id))
        );

        return $this->getModelFromResult($modelResult);
    }
546611
public function findDocumentById($id)
    {
        $response = $this->request('GET', '/' . $id);
        if ($response->getStatusCode() !== 200) {
            return null;
        }

        return $this->documentFactory->createFromResponse($this, $id, $response);
    }
966161
public function getById($id)
    {
        if (isset($this->elements[$id])) {
            return $this->elements[$id];
        }

        throw new \InvalidArgumentException(sprintf('Element for id %s does not exist', $id));
    }
952598
public function getPostCreateItem($id = null)
    {
        $title      = "Skriv ett inlägg";

        $session = $this->di->get("session");
        $sess = $session->get("user");

        if ($sess) {
            $form       = new CreateCommForm($this->di, $sess['id'], $id);
            $form->check();

            $data = [
                "form" => $form->getHTML(),
            ];
        } else {
            $data = [
                "form" => "Enbart för inloggade. Sorry!",
            ];
        }

        $crud = "comm/crud/create";
        $this->toRender($title, $crud, $data);
    }
766140
public function find($id, $attributes = ['*'])
    {
        return $this->executeCallback(get_called_class(), __FUNCTION__, func_get_args(), function () use ($id, $attributes) {
            return $this->prepareQuery($this->createModel())->find($id, $attributes);
        });
    }
971172
public function getForm($id)
    {
        return (isset($this->forms[$id])) ? $this->forms[$id] : null;
    }
1273171
public function getParameterByID($id)
    {
        $param = current(array_filter($this->params, function (Param $param) use ($id) {
            return ($param->id === $id);
        }));

        return ($param) ? $param : null;
    }
1055761
private function get($id) {
        if ($id === 0) {
            $this->response->setError();
            return false;
        }
        $entity = $this->entityManager->find(\Emeric0101\PHPAngular\Config::PHPANGULAR_BUNDLE ."\\Entity\\" . $this->name, $id);
        if ($entity === null) {
            $this->response->setError("NOT_FOUND");
            return false;
        }

        $this->response->setResponse($this->name, $entity);
        return true;
    }
1306946
public function getById($id)
    {
        if (isset($this->idList[$id])) {
            return $this->idList[$id];
        }

        return null;
    }
434665
public static function get($id, $cache = true) {
        if (!$id) {
            return null;
        }
        $model = get_called_class();
        $db_cache = null;
        if ($cache) {
            /* @var $db_cache DBCache */
            $db_cache = Ioc::get(DBCache::class);
            $data = $db_cache->recordCache($model, $id);
            if ($data) {
                return $data;
            }
        }
        /* @var $model Record */
        $model = new $model;
        $pk = $model->getPkField();
        $where[ $pk ] = $id;
        $data = $model::find($where);
        if ($cache && $data) {
            $db_cache->recordCacheSave(get_called_class(), $id, $data->_db_data);
        }
        return $data;
    }
106482
public static function factory($id)
    {
        $id = (string)$id;
        if (!isset(static::$permissions[$id])) {
            static::$permissions[$id] = new static($id);
        }
        return static::$permissions[$id];
    }