]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
remove unused code
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 27 Jul 2013 21:41:15 +0000 (00:41 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 27 Jul 2013 21:41:15 +0000 (00:41 +0300)
ipf/orm/record.php
ipf/orm/record/abstract.php
ipf/orm/record/filter.php [deleted file]
ipf/orm/record/filter/compound.php [deleted file]
ipf/orm/record/filter/standard.php [deleted file]
ipf/orm/table.php

index 29b0e0dfde4a9632c6a47b5b6fff554b5ce76dad..1290ff6341b02d5da22decf047271bcc3656cd9d 100644 (file)
@@ -460,19 +460,11 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
             return $this->_values[$fieldName];
         }
 
-        try {
-            if ( ! isset($this->_references[$fieldName]) && $load) {
-                $rel = $this->_table->getRelation($fieldName);
-                $this->_references[$fieldName] = $rel->fetchRelatedFor($this);
-            }
-            return $this->_references[$fieldName];
-        } catch (IPF_ORM_Exception_Table $e) {
-            foreach ($this->_table->getFilters() as $filter) {
-                if (($value = $filter->filterGet($this, $fieldName, $value)) !== null) {
-                    return $value;
-                }
-            }
+        if (!isset($this->_references[$fieldName]) && $load) {
+            $rel = $this->_table->getRelation($fieldName);
+            $this->_references[$fieldName] = $rel->fetchRelatedFor($this);
         }
+        return $this->_references[$fieldName];
     }
 
     public function mapValue($name, $value)
@@ -515,15 +507,7 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
                 }
             }
         } else {
-            try {
-                $this->coreSetRelated($fieldName, $value);
-            } catch (IPF_ORM_Exception_Table $e) {
-                foreach ($this->_table->getFilters() as $filter) {
-                    if (($value = $filter->filterSet($this, $fieldName, $value)) !== null) {
-                        break;
-                    }
-                }
-            }
+            $this->coreSetRelated($fieldName, $value);
         }
 
         return $this;
@@ -1036,11 +1020,6 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
         return $this;
     }
 
-    public function unshiftFilter(IPF_ORM_Record_Filter $filter)
-    {
-        return $this->_table->unshiftFilter($filter);
-    }
-
     public function unlink($alias, $ids = array())
     {
         $ids = (array) $ids;
index 63651877624a72513f9a6e90740d06c68cd169dd..cf4604656ded33700b51e0c90f4fcb41e6465ac6 100644 (file)
@@ -37,12 +37,6 @@ abstract class IPF_ORM_Record_Abstract extends IPF_ORM_Access
         }    
     }
 
-    public function bindQueryParts(array $queryParts)
-    {
-        $this->_table->bindQueryParts($queryParts);
-        return $this;
-    }
-
     public function loadGenerator(IPF_ORM_Record_Generator $generator)
     {
         $generator->initialize($this->_table);
diff --git a/ipf/orm/record/filter.php b/ipf/orm/record/filter.php
deleted file mode 100644 (file)
index ee65088..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-abstract class IPF_ORM_Record_Filter
-{
-    protected $_table;
-
-    public function setTable(IPF_ORM_Table $table)
-    {
-        $this->_table = $table;
-    }
-
-    public function getTable()
-    {
-        return $this->_table;
-    }
-
-    abstract public function filterSet(IPF_ORM_Record $record, $name, $value);
-    abstract public function filterGet(IPF_ORM_Record $record, $name);
-}
\ No newline at end of file
diff --git a/ipf/orm/record/filter/compound.php b/ipf/orm/record/filter/compound.php
deleted file mode 100644 (file)
index 289136d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-class IPF_ORM_Record_Filter_Compound extends IPF_ORM_Record_Filter
-{
-    protected $_aliases = array();
-
-    public function __construct(array $aliases)
-    {
-        $this->_aliases = $aliases;
-    }
-    public function init()
-    {
-       // check that all aliases exist
-       foreach ($this->_aliases as $alias) {
-            $this->_table->getRelation($alias);
-       }
-    }
-
-    public function filterSet(IPF_ORM_Record $record, $name, $value)
-    {
-        foreach ($this->_aliases as $alias) {
-            if ( ! $record->exists()) {
-                if (isset($record[$alias][$name])) {
-                    $record[$alias][$name] = $value;
-                    
-                    return $record;
-                }
-            } else {
-                // we do not want to execute N + 1 queries here, hence we cannot use get()
-                if (($ref = $record->reference($alias)) !== null) {
-                    if (isset($ref[$name])) {
-                        $ref[$name] = $value;
-                    }
-                    
-                    return $record;
-                }
-            }
-        }
-    }
-
-    public function filterGet(IPF_ORM_Record $record, $name)
-    {
-        foreach ($this->_aliases as $alias) {
-            if ( ! $record->exists()) {
-                if (isset($record[$alias][$name])) {
-                    return $record[$alias][$name];
-                }
-            } else {
-                // we do not want to execute N + 1 queries here, hence we cannot use get()
-                if (($ref = $record->reference($alias)) !== null) {
-                    if (isset($ref[$name])) {
-                        return $ref[$name];
-                    }
-                }
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/ipf/orm/record/filter/standard.php b/ipf/orm/record/filter/standard.php
deleted file mode 100644 (file)
index d76c5c6..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-class IPF_ORM_Record_Filter_Standard extends IPF_ORM_Record_Filter
-{
-    public function filterSet(IPF_ORM_Record $record, $name, $value)
-    {
-        throw new IPF_ORM_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));
-    }
-
-    public function filterGet(IPF_ORM_Record $record, $name)
-    {
-        throw new IPF_ORM_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));
-    }
-}
\ No newline at end of file
index c6427c730a92a3041a99bcfab883ed9d4da48e51..7f87815cbfb367a98b93f8e384331925af78e980 100644 (file)
@@ -33,7 +33,6 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable
     protected $_parser;
 
     protected $_templates   = array();
-    protected $_filters     = array();
     protected $_generators     = array();
     protected $_invokedMethods = array();
 
@@ -63,7 +62,6 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable
 
         $name::setUp($this);
 
-        $this->_filters[]  = new IPF_ORM_Record_Filter_Standard();
         $this->_repository = new IPF_ORM_Table_Repository($this);
     }
 
@@ -734,25 +732,6 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable
         return $record;
     }
 
-    final public function getProxy($id = null)
-    {
-        if ($id !== null) {
-            $identifierColumnNames = $this->getIdentifierColumnNames();
-            $query = 'SELECT ' . implode(', ', (array) $identifierColumnNames)
-                . ' FROM ' . $this->getTableName()
-                . ' WHERE ' . implode(' = ? && ', (array) $identifierColumnNames) . ' = ?';
-            $query = $this->applyInheritance($query);
-
-            $params = array_merge(array($id), array_values($this->_options['inheritanceMap']));
-
-            $this->_data = $this->_conn->execute($query, $params)->fetch(PDO::FETCH_ASSOC);
-
-            if ($this->_data === false)
-                return false;
-        }
-        return $this->getRecord();
-    }
-
     final public function applyInheritance($where)
     {
         if ( ! empty($this->_options['inheritanceMap'])) {
@@ -1071,22 +1050,6 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable
         return $this->_options['queryParts'][$queryPart];
     }
 
-    public function unshiftFilter(IPF_ORM_Record_Filter $filter)
-    {
-        $filter->setTable($this);
-
-        $filter->init();
-
-        array_unshift($this->_filters, $filter);
-
-        return $this;
-    }
-
-    public function getFilters()
-    {
-        return $this->_filters;
-    }
-
     public function __toString()
     {
         return IPF_ORM_Utils::getTableAsString($this);