mirror of
				https://github.com/alchemy-fr/Phraseanet.git
				synced 2025-10-24 18:33:13 +00:00 
			
		
		
		
	 1e18b3e69f
			
		
	
	1e18b3e69f
	
	
	
		
			
			- Squashed Pull request #1730 - Squashed Pull request #1741 - Squashed Pull request #1742 - Squash merge branch 4.0 - Squashed Pull request #1744 - Squashed Pull request #1746 - Squashed merge branch 4.0 - Squashed merge branch 4.0 - Squashed merge branch 4.0 - Squashed merge branch 4.0 - Squashed Pull request #1758 - Avoid using imagine/imagine alias as it is causing install issues - Squashed merge branch 4.0 - Squashed Pull request #1763 - Squashed merge branch 4.0 - Squash of 6 commits - Squashed merge branch 4.0 - This is a combination of 2 commits. - Squashed Pull request #1775 - Squashed Pull request #1777 - Squashed Pull request #1779 - Squashed Pull request #1780 - Squashed Pull request #1782 - Adds a Pull request template - Squased Pull request #1783 - Squash Pull request #1786 - Squashed Pull request #1796 - Squashed merge branch 4.0 - Squash Pull request #1791 - Squashed merge branch 4.0 - Squashed Pull request #1808 - Squashed Pull request #1811 - Squashed Pull request #1809
		
			
				
	
	
		
			155 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			155 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| /*
 | |
|  * This file is part of Phraseanet
 | |
|  *
 | |
|  * (c) 2005-2016 Alchemy
 | |
|  *
 | |
|  * For the full copyright and license information, please view the LICENSE
 | |
|  * file that was distributed with this source code.
 | |
|  */
 | |
| 
 | |
| abstract class set_abstract implements IteratorAggregate
 | |
| {
 | |
|     /**
 | |
|      * @var \record_adapter[]
 | |
|      */
 | |
|     protected $elements = [];
 | |
| 
 | |
|     /**
 | |
|      * @return ArrayIterator
 | |
|      */
 | |
|     public function getIterator()
 | |
|     {
 | |
|         return new ArrayIterator($this->elements);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param  string $offset
 | |
|      * @param  record_adapter $value
 | |
|      * @return void
 | |
|      */
 | |
|     public function offsetSet($offset, $value)
 | |
|     {
 | |
|         if (is_null($offset)) {
 | |
|             $this->elements[] = $value;
 | |
|         } else {
 | |
|             $this->elements[$offset] = $value;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param  string  $offset
 | |
|      * @return bool
 | |
|      */
 | |
|     public function offsetExists($offset)
 | |
|     {
 | |
|         return isset($this->elements[$offset]);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param  string $offset
 | |
|      * @return void
 | |
|      */
 | |
|     public function offsetUnset($offset)
 | |
|     {
 | |
|         unset($this->elements[$offset]);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param  string         $offset
 | |
|      * @return record_adapter|null
 | |
|      */
 | |
|     public function offsetGet($offset)
 | |
|     {
 | |
|         return isset($this->elements[$offset]) ? $this->elements[$offset] : null;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @return bool
 | |
|      */
 | |
|     public function is_empty()
 | |
|     {
 | |
|         return count($this->elements) == 0;
 | |
|     }
 | |
| 
 | |
|     public function __isset($key)
 | |
|     {
 | |
|         trigger_error("Unable to use magic method get for key $key");
 | |
|         if (isset($this->$key)) {
 | |
|             return true;
 | |
|         }
 | |
| 
 | |
|         return false;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Get the number of element in the set
 | |
|      *
 | |
|      * @return int
 | |
|      */
 | |
|     public function get_count()
 | |
|     {
 | |
|         return count($this->elements);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @return int
 | |
|      */
 | |
|     public function get_count_groupings()
 | |
|     {
 | |
|         $n = 0;
 | |
|         foreach ($this->elements as $record) {
 | |
|             if ($record->isStory())
 | |
|                 $n ++;
 | |
|         }
 | |
| 
 | |
|         return $n;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @return record_adapter[]
 | |
|      */
 | |
|     public function get_elements()
 | |
|     {
 | |
|         return $this->elements;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param  record_adapter $record
 | |
|      * @return $this
 | |
|      */
 | |
|     public function add_element(\record_adapter $record)
 | |
|     {
 | |
|         $this->elements[$record->getId()] = $record;
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param  record_adapter $record
 | |
|      * @return $this
 | |
|      */
 | |
|     public function remove_element(\record_adapter $record)
 | |
|     {
 | |
|         $key = $record->getId();
 | |
|         if (isset($this->elements[$key]))
 | |
|             unset($this->elements[$key]);
 | |
| 
 | |
|         return $this;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @return string
 | |
|      */
 | |
|     public function serialize_list()
 | |
|     {
 | |
|         $basrec = [];
 | |
|         foreach ($this->elements as $record) {
 | |
|             $basrec[] = $record->getId();
 | |
|         }
 | |
| 
 | |
|         return implode(';', $basrec);
 | |
|     }
 | |
| }
 |