Пример #1
0
 public static function map(\Sb\Db\Model\Model &$user, array $properties, $prefix = "")
 {
     //        var_dump($properties);
     if (array_key_exists('id', $properties)) {
         $user->setId($properties['id']);
     }
     //        if (array_key_exists('wp_id', $properties)) {
     //            $user->setWpId($properties['wp_id']);
     //        }
     if (array_key_exists('facebook_id', $properties)) {
         $user->setFacebookId($properties['facebook_id']);
     }
     if (array_key_exists('connexion_type', $properties)) {
         $user->setConnexionType($properties['connexion_type']);
     }
     if (array_key_exists('first_name', $properties)) {
         $user->setFirstName(stripslashes($properties['first_name']));
     }
     if (array_key_exists('last_name', $properties)) {
         $user->setLastName(stripslashes($properties['last_name']));
     }
     if (array_key_exists('user_name', $properties)) {
         $user->setUserName(stripslashes($properties['user_name']));
     }
     if (array_key_exists('email', $properties)) {
         $user->setEmail($properties['email']);
     }
     if (array_key_exists('password', $properties)) {
         if (!empty($properties['password'])) {
             $user->setPassword(sha1($properties['password']));
         }
     }
     if (array_key_exists('gender', $properties)) {
         $user->setGender($properties['gender']);
     }
     if (array_key_exists('address', $properties)) {
         $user->setAddress($properties['address']);
     }
     if (array_key_exists('city', $properties)) {
         $user->setCity($properties['city']);
     }
     if (array_key_exists('zipCode', $properties)) {
         $user->setZipCode($properties['zipCode']);
     }
     if (array_key_exists('country', $properties)) {
         $user->setCountry($properties['country']);
     }
     if (array_key_exists('birthday', $properties)) {
         $user->setBirthDay(\Sb\Helpers\DateHelper::createDate($properties['birthDay']));
     }
     if (array_key_exists('facebook_language', $properties)) {
         $user->setFacebookLanguage($properties['facebook_language']);
     }
     if (array_key_exists('language', $properties)) {
         $user->setLanguage($properties['language']);
     }
     if (array_key_exists('token', $properties)) {
         $user->setToken($properties['token']);
     }
     if (array_key_exists('token_facebook', $properties)) {
         $user->setTokenFacebook($properties['token_facebook']);
     }
     if (array_key_exists('TokenFacebook', $properties)) {
         $user->setTokenFacebook($properties['TokenFacebook']);
     }
     if (array_key_exists('activated', $properties)) {
         $user->setActivated($properties['activated']);
     }
     if (array_key_exists('deleted', $properties)) {
         $user->setDeleted($properties['deleted']);
     }
     if (array_key_exists('gravatar', $properties)) {
         $user->setGravatar($properties['gravatar']);
     }
     if (array_key_exists('picture', $properties)) {
         $user->setPicture($properties['picture']);
     }
     if (array_key_exists('picture_big', $properties)) {
         $user->setPictureBig($properties['picture_big']);
     }
     if (array_key_exists('created', $properties)) {
         $user->setCreated(\Sb\Helpers\DateHelper::createDate($properties['created']));
     }
     if (array_key_exists('last_login', $properties)) {
         $user->setLastLogin(\Sb\Helpers\DateHelper::createDate($properties['last_login']));
     }
 }
Пример #2
0
 public static function mapFromAmazonResult(\Sb\Db\Model\Book &$book, \Zend_Service_Amazon_Item $amazonResult)
 {
     if (isset($amazonResult->Language)) {
         $book->setLanguage($amazonResult->Language);
     }
     if (isset($amazonResult->Author)) {
         $contributors = new \Doctrine\Common\Collections\ArrayCollection();
         if (is_array($amazonResult->Author)) {
             foreach ($amazonResult->Author as $author) {
                 $contributor = new \Sb\Db\Model\Contributor();
                 $contributor->setFullName($author);
                 $contributors->add($contributor);
             }
         } else {
             $contributor = new \Sb\Db\Model\Contributor();
             $contributor->setFullName($amazonResult->Author);
             $contributors->add($contributor);
         }
         $book->setContributors($contributors);
     }
     if (isset($amazonResult->EditorialReviews)) {
         if (count($amazonResult->EditorialReviews) > 0) {
             //$book->setDescription($amazonResult->EditorialReviews[0]->Content);
             // Replace all HTML in description by ' ' to prevent bad formatting HTML
             $book->setDescription(preg_replace('/<[^>]*>/', ' ', $amazonResult->EditorialReviews[0]->Content));
         }
     }
     if (isset($amazonResult->ISBN)) {
         $book->setISBN10($amazonResult->ISBN);
     }
     if (isset($amazonResult->EAN)) {
         $book->setISBN13($amazonResult->EAN);
     }
     if (isset($amazonResult->ASIN)) {
         $book->setASIN($amazonResult->ASIN);
     }
     if (isset($amazonResult->SmallImage)) {
         if ($amazonResult->SmallImage && $amazonResult->SmallImage->Url) {
             $book->setSmallImageUrl($amazonResult->SmallImage->Url->getUri());
         }
     }
     if (isset($amazonResult->MediumImage)) {
         if ($amazonResult->MediumImage && $amazonResult->MediumImage->Url) {
             $book->setImageUrl($amazonResult->MediumImage->Url->getUri());
         }
     }
     if (isset($amazonResult->LargeImage)) {
         if ($amazonResult->LargeImage && $amazonResult->LargeImage->Url) {
             $book->setLargeImageUrl($amazonResult->LargeImage->Url->getUri());
         }
     }
     //Publisher
     if (isset($amazonResult->PublicationDate)) {
         $book->setPublishingDate(\Sb\Helpers\DateHelper::createDate($amazonResult->PublicationDate));
     }
     if (isset($amazonResult->Publisher)) {
         $publisher = new \Sb\Db\Model\Publisher();
         $publisher->setName($amazonResult->Publisher);
         $book->setPublisher($publisher);
     }
     if (isset($amazonResult->Title)) {
         $book->setTitle($amazonResult->Title);
     }
     if (isset($amazonResult->DetailPageURL)) {
         $book->setAmazonUrl($amazonResult->DetailPageURL);
     }
     if (isset($amazonResult->NumberOfPages)) {
         $book->setNb_of_pages($amazonResult->NumberOfPages);
     }
 }