Пример #1
0
 /**
  * Delete the named preference
  *
  * WARNING: You need to EntityManager::flush() if the return > 0!
  *
  * @param string $name The named attribute / preference to check for
  * @param int $index default null If an indexed preference then delete a specific index, if null then delete all
  * @return int The number of preferences deleted
  */
 public function deleteAssocPreference($name, $index = null)
 {
     $count = 0;
     foreach ($this->getPreferences() as $pref) {
         if (strpos($pref->getName(), $name) === 0 && ($index === null || $pref->getIx() == $index)) {
             $this->getPreferences()->removeElement($pref);
             \D2EM::remove($pref);
             $count++;
         }
     }
     return $count;
 }