Finds an object with the given id in this ObjectManager's query.

@param boolean $createOnNoId
@return ObjectWrapperInterface
@throws \Exception If object can not be found.
767051
protected function getObjectOr404($createOnNoId = false)
    {
        /** @var integer|null $objectId */
        $objectId = static::getObjectId();

        /** @var ObjectWrapperInterface $object */
        $object = null;

        if ($objectId !== null) {
            $object = $this->getQuery()->findOneByPrimaryKey($objectId);
        } elseif ($createOnNoId === true) {
            $object = $this->getQuery()->createObject();
        }

        if ($object === null) {
            http_response_code(404);
            throw new \Exception('Object not found.');
        }

        return $object;
    }
5256
public static function parse($oid) {
    // fast checks first
    if ($oid instanceof ObjectId) {
      return $oid;
    }

    $oidParts = self::parseOidString($oid);
    $type = $oidParts['type'];
    $ids = $oidParts['id'];
    $prefix = $oidParts['prefix'];

    // check the type
    if (!ObjectFactory::getInstance('persistenceFacade')->isKnownType($type)) {
      return null;
    }

    // check if number of ids match the type
    $numPks = self::getNumberOfPKs($type);
    if ($numPks == null || $numPks != sizeof($ids)) {
      return null;
    }

    return new ObjectID($type, $ids, $prefix);
  }
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;
    }
330980
public function beginOnce()
    {
        $this->createQuery();

        GapOrm::getDriver()->query($this->getQuery(), []);

        $obj = GapOrm::getDriver()->selectOnce();
        $obj = $this->convertFromDB($obj);

        if ($obj) {
            return $obj;
        }

        return null;
    }
1371954
public function NewObject() {
		$id = (int) $this->request->requestVar('new');
		if ($id) {
			$item = DataObject::get_by_id($this->CreateType, $id);
			if (!$item) {
				$item = Versioned::get_by_stage($this->CreateType, 'Stage')->byID($id);
			}
			return $item;
		}

		return null;
	}
1317814
private function doFind($id)
    {
        $id = $this->toIdentity($id);
        $entity = null === $id ? null : $this->em->find($this->class, $id);

        if (null === $entity) {
            throw EntityNotFoundException::createForId($this->class, $id);
        }

        return $entity;
    }
287349
protected function loadObject($objId)
    {
        if ($objId instanceof ModelInterface) {
            return $objId;
        }

        $obj = $this->modelLoader()->load($objId);
        if (!$obj->id()) {
            return null;
        } else {
            return $obj;
        }
    }
568364
public function objectRestore($iObjectId)
    {
        $oDb = Factory::service('Database');

        try {

            $oObject = $this->getObjectFromTrash($iObjectId);
            if (empty($oObject)) {
                throw new CdnException('Not a valid object');
            }

            // --------------------------------------------------------------------------

            $aObjectData = [
                'id'               => $oObject->id,
                'bucket_id'        => $oObject->bucket->id,
                'filename'         => $oObject->file->name->disk,
                'filename_display' => $oObject->file->name->human,
                'mime'             => $oObject->file->mime,
                'filesize'         => $oObject->file->size->bytes,
                'img_width'        => $oObject->img_width,
                'img_height'       => $oObject->img_height,
                'img_orientation'  => $oObject->img_orientation,
                'is_animated'      => $oObject->is_animated,
                'serves'           => $oObject->serves,
                'downloads'        => $oObject->downloads,
                'thumbs'           => $oObject->thumbs,
                'scales'           => $oObject->scales,
                'driver'           => $oObject->driver,
                'created'          => $oObject->created,
                'created_by'       => $oObject->created_by,
            ];

            if (isLoggedIn()) {
                $aObjectData['modified_by'] = activeUser('id');
            }

            $oDb->set($aObjectData);
            $oDb->set('modified', 'NOW()', false);

            //  Start transaction
            $oDb->trans_begin();

            //  Restore object
            if (!$oDb->insert(NAILS_DB_PREFIX . 'cdn_object')) {
                throw new CdnException('Failed to restore original object.');
            }

            //  Remove trash object
            $oDb->where('id', $oObject->id);
            if (!$oDb->delete(NAILS_DB_PREFIX . 'cdn_object_trash')) {
                throw new CdnException('Failed to remove the trash object.');
            }

            $oDb->trans_commit();

            return true;

        } catch (\Exception $e) {
            $oDb->trans_rollback();
            $this->setError($e->getMessage());
            return false;
        }
    }
753993
public function findObject($entity, $_id)
	{
		$retValue = array();

		try{
			$m = new MongoDB\Driver\Manager($this->url);

			$id = new \MongoDB\BSON\ObjectId($_id);
			$filter = ['_id' => $id];
			$options = [];

			$query = new \MongoDB\Driver\Query($filter, $options);
			$mCol = $this->db . "."  . $entity;
			$jsonData = $m->executeQuery($mCol, $query);

			$retValue = $jsonData->toArray();
		}
		catch(Exception $e) {
			$this->_log->addError($e->getMessage());
		}

		return $retValue;
	}
318603
public static function create($object, $beforeCallable = null, $afterCallable = null, $bothCallable = null)
    {
        $wrapperObject = new Wrapper($object);
        if (is_callable($beforeCallable)) {
            $wrapperObject->registerOnBefore($beforeCallable);
        }

        if (is_callable($afterCallable)) {
            $wrapperObject->registerOnAfter($afterCallable);
        }

        if (is_callable($bothCallable)) {
            $wrapperObject->registerOnBoth($bothCallable);
        }

        return $wrapperObject;
    }
730022
public function make(string $id, array $parameters = [], bool $createNew = false)
    {
        if (isset($this->alias[$id])) {
            $id = $this->alias[$id];
        }

        if ($createNew || ! isset($this->objects[$id])) {
            $concrete = isset($this->bindings[$id]) ?
                        $this->bindings[$id] :
                        $id;

            $this->objects[$id] = $this->resolve($concrete, $parameters);
        }

        return $this->objects[$id];
    }
804971
public function get($id) {
		// if there's no parent and we don't have one, it's not found
		if($this->parent === null && !array_key_exists($id, $this->instances)) {
			// try to make it
			try {
				return $this->instantiate($id);
			} catch(\Exception $e) {
				// throw RefNotFound if we couldn't build one
				throw new RefNotFound($id);
			}
		}

		// return either ours or our parent's
		return array_key_exists($id, $this->instances) ? $this->instances[$id] : $this->parent->get($id);
	}
815422
public function extend($id, callable $callback)
    {
        if (!$this->has($id)) {
            throw new Exception\NotFoundException;
        }
        $oldCallback = $this->callbacks[$id];
        $this->callbacks[$id] = function () use ($oldCallback, $callback, $id) {
            if (!$this->isReady($id)) {
                $thisFunction = $this->callbacks[$id];
                $this->callbacks[$id] = $oldCallback;
                $this->instantiate($id);
                $this->callbacks[$id] = $thisFunction;
            }
            $instance = $this->instances[$id];
            $newInstance = call_user_func($callback, $instance, $this);
            return $newInstance ?: $instance;
        };
        if ($this->isReady($id)) {
            $instance = $this->instances[$id];
            $newInstance = call_user_func($callback, $instance, $this);
            $this->instances[$id] = $newInstance ?: $instance;
        }
        return $this;
    }
831910
public function find(
        string $entityNamespace,
        $id
    ) {
        return $this
            ->getObjectRepository($this->locateEntity($entityNamespace))
            ->find($id);
    }
194804
public function getObjectService(string $objectType): AbstractStandaloneObject
    {
        //====================================================================//
        // Safety Check
        if (!isset($this->taggedObjects[$objectType])) {
            throw new Exception(sprintf('Standalone Object  "%s" is not defined. Did you tag your service as  "splash.standalone.object"?', $objectType));
        }
        //====================================================================//
        // Configure Object Service
        $this->taggedObjects[$objectType]->configure($objectType, $this->getWebserviceId(), $this->getConfiguration());
        //====================================================================//
        // Connect to Object Service
        return $this->taggedObjects[$objectType];
    }
88645
public function get($id)
    {
        if (false === $this->has($id)) {
            $errMsg = sprintf('Invalid create %s', $id);
            throw new Exception\NotFoundDoctrineObjectHydratorException($errMsg);
        }

        return clone $this->prototype[$id];
    }
392255
public function get($objectId)
    {
        $response = $this->api->get($this->url($objectId));
        $className = $this->objectClass;

        return new $className($this->api, $this, $response->data);
    }