Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[DCOM-28] Initial entry of Doctrine Persistence API interfaces.

  • Loading branch information...
commit 59e6b8c6edcb271622923035b687a063c2b47ce8 1 parent 602de4d
@jwage jwage authored
View
88 lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php
@@ -0,0 +1,88 @@
+<?php
+/*
+ * $Id$
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Persistence\Mapping;
+
+/**
+ * Contract for a Doctrine persistence layer ClassMetadata class to implement.
+ *
+ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
+ * @link www.doctrine-project.org
+ * @since 2.1
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @author Jonathan Wage <jonwage@gmail.com>
+ */
+interface ClassMetadata
+{
+ /**
+ * Gets the mapped identifier field name.
+ *
+ * @return mixed
+ */
+ public function getIdentifier();
+
+ /**
+ * Gets the ReflectionClass instance for this mapped class.
+ *
+ * @return ReflectionClass
+ */
+ public function getReflectionClass();
+
+ /**
+ * Checks if the given field name is a mapped identifier for this class.
+ *
+ * @param string $fieldName
+ * @return boolean
+ */
+ public function isIdentifier($fieldName);
+
+ /**
+ * Checks if the given field is a mapped property for this class.
+ *
+ * @param string $fieldName
+ * @return boolean
+ */
+ public function hasField($fieldName);
+
+ /**
+ * Checks if the given field is a mapped association for this class.
+ *
+ * @param string $fieldName
+ * @return boolean
+ */
+ public function hasAssociation($fieldName);
+
+ /**
+ * Checks if the given field is a mapped single valued association for this class.
+ *
+ * @param string $fieldName
+ * @return boolean
+ */
+ public function isSingleValuedAssociation($fieldName);
+
+ /**
+ * Checks if the given field is a mapped collection valued association for this class.
+ *
+ * @param string $fieldName
+ * @return boolean
+ */
+ public function isCollectionValuedAssociation($fieldName);
+}
View
120 lib/Doctrine/Common/Persistence/ObjectManager.php
@@ -0,0 +1,120 @@
+<?php
+/*
+ * $Id$
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Persistence;
+
+/**
+ * Contract for a Doctrine persistence layer ObjectManager class to implement.
+ *
+ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
+ * @link www.doctrine-project.org
+ * @since 2.1
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @author Jonathan Wage <jonwage@gmail.com>
+ */
+interface ObjectManager
+{
+ /**
+ * Finds a object by its identifier.
+ *
+ * This is just a convenient shortcut for getRepository($className)->find($id).
+ *
+ * @param string
+ * @param mixed
+ * @return object
+ */
+ public function find($className, $id);
+
+ /**
+ * Tells the ObjectManager to make an instance managed and persistent.
+ *
+ * The object will be entered into the database as a result of the flush operation.
+ *
+ * NOTE: The persist operation always considers objects that are not yet known to
+ * this ObjectManager as NEW. Do not pass detached objects to the persist operation.
+ *
+ * @param object $object The instance to make managed and persistent.
+ */
+ public function persist($object);
+
+ /**
+ * Removes an object instance.
+ *
+ * A removed object will be removed from the database as a result of the flush operation.
+ *
+ * @param object $object The object instance to remove.
+ */
+ public function remove($object);
+
+ /**
+ * Merges the state of a detached object into the persistence context
+ * of this ObjectManager and returns the managed copy of the object.
+ * The object passed to merge will not become associated/managed with this ObjectManager.
+ *
+ * @param object $object
+ */
+ public function merge($object);
+
+ /**
+ * Detaches an object from the ObjectManager, causing a managed object to
+ * become detached. Unflushed changes made to the object if any
+ * (including removal of the object), will not be synchronized to the database.
+ * Objects which previously referenced the detached object will continue to
+ * reference it.
+ *
+ * @param object $object The object to detach.
+ */
+ public function detach($object);
+
+ /**
+ * Refreshes the persistent state of an object from the database,
+ * overriding any local changes that have not yet been persisted.
+ *
+ * @param object $object The object to refresh.
+ */
+ public function refresh($object);
+
+ /**
+ * Flushes all changes to objects that have been queued up to now to the database.
+ * This effectively synchronizes the in-memory state of managed objects with the
+ * database.
+ */
+ public function flush();
+
+ /**
+ * Gets the repository for an entity class.
+ *
+ * @param string $className
+ * @return \Doctrine\Common\Persistence\ObjectRepository
+ */
+ public function getRepository($className);
+
+ /**
+ * Returns the ClassMetadata descriptor for a class.
+ *
+ * The class name must be the fully-qualified class name without a leading backslash
+ * (as it is returned by get_class($obj)).
+ *
+ * @param string $className
+ * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
+ */
+ public function getClassMetadata($className);
+}
View
65 lib/Doctrine/Common/Persistence/ObjectRepository.php
@@ -0,0 +1,65 @@
+<?php
+/*
+ * $Id$
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Persistence;
+
+/**
+ * Contract for a Doctrine persistence layer ObjectRepository class to implement.
+ *
+ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
+ * @link www.doctrine-project.org
+ * @since 2.1
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @author Jonathan Wage <jonwage@gmail.com>
+ */
+interface ObjectRepository
+{
+ /**
+ * Finds an object by its primary key / identifier.
+ *
+ * @param $id The identifier.
+ * @return object The object.
+ */
+ public function find($id);
+
+ /**
+ * Finds all objects in the repository.
+ *
+ * @return mixed The objects.
+ */
+ public function findAll();
+
+ /**
+ * Finds objects by a set of criteria.
+ *
+ * @param array $criteria
+ * @return mixed The objects.
+ */
+ public function findBy(array $criteria);
+
+ /**
+ * Finds a single object by a set of criteria.
+ *
+ * @param array $criteria
+ * @return object The object.
+ */
+ public function findOneBy(array $criteria);
+}

2 comments on commit 59e6b8c

@beberlei
Owner

Can we call it ObjectMetadata instead of ClassMetadata? I hate the use foo as bar; renaming.

@beberlei
Owner

The $Id$ in the head can be removed also, its SVN legacy.

Please sign in to comment.
Something went wrong with that request. Please try again.