/**
  * {@inheritDoc}
  */
 public function insert($storageName, $key, array $data)
 {
     $entity = $this->createEntity($key, $data);
     try {
         $this->client->insertEntity($storageName, $entity);
     } catch (ServiceException $e) {
         if ($e->getCode() == 404) {
             $this->client->createTable($storageName);
         } else {
             throw new StorageException("Could not save entity in table, WindowsAzure SDK client reported error: " . $e->getMessage(), $e->getCode(), $e);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Store an Aggregation in DB
  *
  * @param \Agg\Entity\Aggregation $aggregation
  */
 public function storeAggregation($aggregation)
 {
     //Generate unique slug
     $slug = $this->getUniqueSlug($this->slugify($aggregation->getTitle()));
     $aggregation->setSlug($slug);
     $entity = new Entity();
     $entity->setPartitionKey("talk");
     $entity->setRowKey($slug);
     $entity->addProperty("slug", EdmType::STRING, $aggregation->getSlug());
     $entity->addProperty("title", EdmType::STRING, $aggregation->getTitle());
     $entity->addProperty("talks", EdmType::STRING, serialize($aggregation->getTalks()));
     $entity->addProperty("speakerName", EdmType::STRING, $aggregation->getSpeakerName());
     $entity->addProperty("speakerUrl", EdmType::STRING, $aggregation->getSpeakerUrl());
     try {
         $this->tableProxy->insertEntity(self::TABLE_AGGREGATION, $entity);
     } catch (ServiceException $e) {
         $code = $e->getCode();
         $error_message = $e->getMessage();
         echo $code . ": " . $error_message . "<br />";
     }
 }