当前位置: 首页>>代码示例>>PHP>>正文


PHP record_adapter::createFromFile方法代码示例

本文整理汇总了PHP中record_adapter::createFromFile方法的典型用法代码示例。如果您正苦于以下问题:PHP record_adapter::createFromFile方法的具体用法?PHP record_adapter::createFromFile怎么用?PHP record_adapter::createFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在record_adapter的用法示例。


在下文中一共展示了record_adapter::createFromFile方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRenewUrl

 /**
  * @covers Alchemy\Phrasea\Controller\Prod\Records::renewUrl
  */
 public function testRenewUrl()
 {
     $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']);
     $record = \record_adapter::createFromFile($file, self::$DI['app']);
     $this->XMLHTTPRequest('POST', '/prod/records/renew-url/', ['lst' => $record->get_serialize_key()]);
     $response = self::$DI['client']->getResponse();
     $datas = (array) json_decode($response->getContent());
     $this->assertTrue(count($datas) > 0);
     $record->delete();
     unset($response, $datas, $record);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:14,代码来源:RecordsTest.php

示例2: bootTestCase

 public function bootTestCase()
 {
     $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . "/../../files/iphone_pic.jpg"), self::$DI['collection']);
     self::$recordonbleu = record_adapter::createFromFile($file, self::$DI['app']);
     self::$DI['app']['subdef.generator']->generateSubdefs(self::$recordonbleu);
     foreach (self::$recordonbleu->get_subdefs() as $subdef) {
         if ($subdef->get_name() == 'document') {
             continue;
         }
         if (!self::$objectPresent) {
             self::$objectPresent = $subdef;
             continue;
         }
         if (!self::$objectNotPresent) {
             self::$objectNotPresent = $subdef;
             continue;
         }
     }
     self::$objectNotPresent->remove_file();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:20,代码来源:subdefTest.php

示例3: testMoveRecordToCollection

 public function testMoveRecordToCollection()
 {
     self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
     $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/test001.jpg'), self::$DI['collection']);
     $record = \record_adapter::createFromFile($file, self::$DI['app']);
     $this->setToken($this->userAccessToken);
     $route = '/api/v1/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setcollection/';
     $base_id = false;
     foreach ($record->get_databox()->get_collections() as $collection) {
         if ($collection->get_base_id() != $record->get_base_id()) {
             $base_id = $collection->get_base_id();
             break;
         }
     }
     if (!$base_id) {
         $this->markTestSkipped('No collection');
     }
     $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']);
     self::$DI['client']->request('POST', $route, $this->getParameters(['base_id' => $base_id]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]);
     $content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
     $this->evaluateResponse200(self::$DI['client']->getResponse());
     $this->evaluateMeta200($content);
     $record->delete();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:24,代码来源:ApiTestCase.php

示例4: generateRecord

 private function generateRecord(\Pimple $DI)
 {
     foreach (range(1, 7) as $i) {
         $file = new File($this->container, $this->container['mediavorus']->guess(__DIR__ . '/../../../../../tests/files/test001.jpg'), $DI['coll']);
         $record = \record_adapter::createFromFile($file, $this->container);
         $this->container['subdef.generator']->generateSubdefs($record);
         $DI['record_' . $i] = $record;
     }
     $media = $this->container['mediavorus']->guess($this->container['root.path'] . '/tests/files/cestlafete.jpg');
     foreach (range(1, 3) as $i) {
         $story = \record_adapter::createStory($this->container, $DI['coll']);
         if ($i < 3) {
             $this->container['subdef.substituer']->substitute($story, 'preview', $media);
             $this->container['subdef.substituer']->substitute($story, 'thumbnail', $media);
         }
         $DI['record_story_' . $i] = $story;
     }
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:18,代码来源:RegenerateSqliteDb.php

示例5: testEmptyDatabase

 /**
  * @covers \Alchemy\Phrasea\Controller\Admin\Database::emptyDatabase
  */
 public function testEmptyDatabase()
 {
     $this->setAdmin(true);
     $base = $this->createDatabox();
     $collection = \collection::create(self::$DI['app'], $base, self::$DI['app']['phraseanet.appbox'], 'TESTTODELETE');
     self::$createdCollections[] = $collection;
     $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/test001.jpg'), $collection);
     \record_adapter::createFromFile($file, self::$DI['app']);
     if ($collection->get_record_amount() === 0) {
         $this->markTestSkipped('No record were added');
     }
     $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/empty/');
     $json = $this->getJson(self::$DI['client']->getResponse());
     $this->assertTrue($json->success);
     $this->assertEquals(0, $collection->get_record_amount());
     $base->unmount_databox();
     $base->delete();
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:21,代码来源:DataboxTest.php

示例6: testDeleteCollectionNoEmpty

 /**
  * @covers Alchemy\Phrasea\Controller\Admin\Bas::delete
  */
 public function testDeleteCollectionNoEmpty()
 {
     $this->setAdmin(true);
     $collection = $this->createOneCollection();
     $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/test001.jpg'), $collection);
     \record_adapter::createFromFile($file, self::$DI['app']);
     if ($collection->get_record_amount() === 0) {
         $this->markTestSkipped('No record were added');
     }
     $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/delete/');
     $json = $this->getJson(self::$DI['client']->getResponse());
     $this->assertFalse($json->success);
     $collection->empty_collection();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:17,代码来源:AdminCollectionTest.php

示例7: testChangeType

 /**
  * @covers Alchemy\Phrasea\Controller\Prod\Property::changeType
  */
 public function testChangeType()
 {
     $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']);
     $record = \record_adapter::createFromFile($file, self::$DI['app']);
     $record2 = \record_adapter::createFromFile($file, self::$DI['app']);
     self::$DI['client']->request('POST', '/prod/records/property/type/', ['lst' => implode(';', [$record->get_serialize_key(), $record2->get_serialize_key()]), 'types' => [$record->get_serialize_key() => 'document', $record2->get_serialize_key() => 'flash']]);
     $response = self::$DI['client']->getResponse();
     $datas = (array) json_decode($response->getContent());
     $this->assertArrayHasKey('success', $datas);
     $this->assertTrue($datas['success']);
     $this->assertArrayHasKey('updated', $datas);
     $record = new \record_adapter(self::$DI['app'], $record->get_sbas_id(), $record->get_record_id());
     $record2 = new \record_adapter(self::$DI['app'], $record2->get_sbas_id(), $record2->get_record_id());
     $this->assertEquals('document', $record->get_type());
     $this->assertEquals('flash', $record2->get_type());
     $record->delete();
     $record2->delete();
     unset($response, $datas, $record2, $record, $file);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:22,代码来源:PropertyTest.php

示例8: testGet_record_details

 public function testGet_record_details()
 {
     $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$object);
     $record = record_adapter::createFromFile($file, self::$DI['app']);
     $details = self::$object->get_record_details();
     $this->assertTrue(is_array($details));
     foreach ($details as $detail) {
         $this->assertTrue(is_array($detail));
         $this->assertArrayHasKey('coll_id', $detail);
         $this->asserttrue(is_int($detail['coll_id']));
         $this->assertArrayHasKey('name', $detail);
         $this->asserttrue(is_string($detail['name']));
         $this->assertArrayHasKey('amount', $detail);
         $this->asserttrue(is_int($detail['amount']));
         $this->assertArrayHasKey('size', $detail);
         $this->asserttrue(is_int($detail['size']));
     }
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:18,代码来源:collectionTest.php

示例9: setUp


//.........这里部分代码省略.........
     });
     self::$DI['user_notAdmin'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit_not_admin']);
     });
     self::$DI['user_alt1'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit_alt1']);
     });
     self::$DI['user_alt2'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['test_phpunit_alt2']);
     });
     self::$DI['user_template'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.user']->getRepository()->find(self::$fixtureIds['user']['user_template']);
     });
     self::$DI['registration_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.registration']->getRepository()->find(self::$fixtureIds['registrations']['registration_1']);
     });
     self::$DI['registration_2'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.registration']->getRepository()->find(self::$fixtureIds['registrations']['registration_2']);
     });
     self::$DI['registration_3'] = self::$DI->share(function ($DI) {
         return $DI['app']['manipulator.registration']->getRepository()->find(self::$fixtureIds['registrations']['registration_3']);
     });
     self::$DI['oauth2-app-user'] = self::$DI->share(function ($DI) {
         return new \API_OAuth2_Application($DI['app'], self::$fixtureIds['oauth']['user']);
     });
     self::$DI['oauth2-app-user_notAdmin'] = self::$DI->share(function ($DI) {
         return new \API_OAuth2_Application($DI['app'], self::$fixtureIds['oauth']['user_notAdmin']);
     });
     self::$DI['logger'] = self::$DI->share(function () {
         $logger = new Logger('tests');
         $logger->pushHandler(new NullHandler());
         return $logger;
     });
     self::$DI['collection'] = self::$DI->share(function ($DI) {
         return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll']);
     });
     self::$DI['collection_no_access'] = self::$DI->share(function ($DI) {
         return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_access']);
     });
     self::$DI['collection_no_access_by_status'] = self::$DI->share(function ($DI) {
         return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_status']);
     });
     if (!self::$booted) {
         if (!self::$DI['app']['phraseanet.configuration-tester']->isInstalled()) {
             echo "[0;31mPhraseanet is not set up[0;37m\n";
             exit(1);
         }
         self::$fixtureIds = array_merge(self::$fixtureIds, json_decode(file_get_contents(__DIR__ . '/../fixtures.json'), true));
         self::resetUsersRights(self::$DI['app'], self::$DI['user']);
         self::resetUsersRights(self::$DI['app'], self::$DI['user_notAdmin']);
         self::$booted = true;
     }
     self::$DI['lazaret_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['EM']->find('Phraseanet:LazaretFile', self::$fixtureIds['lazaret']['lazaret_1']);
     });
     foreach (range(1, 7) as $i) {
         self::$DI['record_' . $i] = self::$DI->share(function ($DI) use($i) {
             return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_' . $i]);
         });
     }
     foreach (range(1, 3) as $i) {
         self::$DI['record_story_' . $i] = self::$DI->share(function ($DI) use($i) {
             return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_story_' . $i]);
         });
     }
     self::$DI['record_no_access_resolver'] = self::$DI->protect(function () {
         $id = 'no_access';
         if (isset(self::$fixtureIds['records'][$id])) {
             return self::$fixtureIds['records'][$id];
         }
         self::$recordsInitialized[] = $id;
         $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access']);
         $record = record_adapter::createFromFile($file, self::$DI['app']);
         self::$DI['app']['subdef.generator']->generateSubdefs($record);
         self::$fixtureIds['records'][$id] = $record->get_record_id();
         return self::$fixtureIds['records'][$id];
     });
     self::$DI['record_no_access_by_status_resolver'] = self::$DI->protect(function () {
         $id = 'no_access_by_status';
         if (isset(self::$fixtureIds['records'][$id])) {
             return self::$fixtureIds['records'][$id];
         }
         self::$recordsInitialized[] = $id;
         $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access_by_status']);
         $record = record_adapter::createFromFile($file, self::$DI['app']);
         self::$DI['app']['subdef.generator']->generateSubdefs($record);
         self::$fixtureIds['records'][$id] = $record->get_record_id();
         return self::$fixtureIds['records'][$id];
     });
     self::$DI['record_no_access'] = self::$DI->share(function ($DI) {
         return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_resolver']());
     });
     self::$DI['record_no_access_by_status'] = self::$DI->share(function ($DI) {
         return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_by_status_resolver']());
     });
     if (!self::$testCaseBooted) {
         $this->bootTestCase();
     }
     self::$testCaseBooted = true;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:101,代码来源:PhraseanetTestCase.php

示例10: testSearchWithRecords

 public function testSearchWithRecords()
 {
     $this->authenticate(self::$DI['app']);
     $record = \record_adapter::createFromFile(BorderFile::buildFromPathfile(__DIR__ . '/../../../files/cestlafete.jpg', self::$DI['collection'], self::$DI['app']), self::$DI['app']);
     $request = new Request(['search_type' => 0], [], [], [], [], ['HTTP_Accept' => 'application/json']);
     $result = $this->object->search($request);
     $this->assertEquals(200, $result->get_http_code());
     $this->assertEquals('application/json', $result->get_content_type());
     $this->assertTrue(is_array(json_decode($result->format(), true)));
     $data = json_decode($result->format(), true);
     $this->assertArrayHasKey('records', $data['response']['results']);
     $this->assertArrayHasKey('stories', $data['response']['results']);
     $found = false;
     foreach ($data['response']['results']['records'] as $retRecord) {
         if ($retRecord['record_id'] == $record->get_record_id() && $retRecord['databox_id'] == $record->get_sbas_id()) {
             $found = true;
             break;
         }
     }
     if (!$found) {
         $this->fail('unable to find the record back');
     }
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:23,代码来源:adapterTest.php

示例11: createRecord

 /**
  * Adds a record to Phraseanet
  *
  * @param  File           $file The package file
  * @return \record_adater
  */
 protected function createRecord(File $file, $nosubdef = false)
 {
     $element = \record_adapter::createFromFile($file, $this->app);
     $date = new \DateTime();
     $file->addAttribute(new MetadataAttr(new Metadata(new TfArchivedate(), new MonoValue($date->format('Y/m/d H:i:s')))));
     $file->addAttribute(new MetadataAttr(new Metadata(new TfRecordid(), new MonoValue($element->get_record_id()))));
     $file->addAttribute(new MetadataAttr(new Metadata(new TfBasename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_BASENAME)))));
     $file->addAttribute(new MetadataAttr(new Metadata(new TfFilename(), new MonoValue(pathinfo($file->getOriginalName(), PATHINFO_FILENAME)))));
     $newMetadata = $file->getMedia()->getMetadatas()->toArray();
     foreach ($file->getAttributes() as $attribute) {
         switch ($attribute->getName()) {
             case AttributeInterface::NAME_METAFIELD:
                 $values = $attribute->getValue();
                 $value = $attribute->getField()->is_multi() ? new Multi($values) : new MonoValue(array_pop($values));
                 $tag = $attribute->getField()->get_tag();
                 if ($tag instanceof \Alchemy\Phrasea\Metadata\Tag\Nosource) {
                     $tag->setTagname($attribute->getField()->get_name());
                     $_meta = new Metadata($tag, $value);
                 } else {
                     $_meta = new Metadata($attribute->getField()->get_tag(), $value);
                 }
                 $newMetadata[] = $_meta;
                 break;
             case AttributeInterface::NAME_METADATA:
                 $newMetadata[] = $attribute->getValue();
                 break;
             case AttributeInterface::NAME_STATUS:
                 $element->set_binary_status(decbin(bindec($element->get_status()) | bindec($attribute->getValue())));
                 break;
             case AttributeInterface::NAME_STORY:
                 $story = $attribute->getValue();
                 if (!$story->hasChild($element)) {
                     $story->appendChild($element);
                 }
                 break;
         }
     }
     $this->app['phraseanet.metadata-setter']->replaceMetadata($newMetadata, $element);
     if (!$nosubdef) {
         $element->rebuild_subdefs();
     }
     return $element;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:49,代码来源:Manager.php

示例12: createRecord

 /**
  * Adds a record to Phraseanet
  *
  * @param  File           $file The package file
  * @return \record_adater
  */
 protected function createRecord(File $file)
 {
     $element = \record_adapter::createFromFile($file, $this->app);
     $date = new \DateTime();
     $file->addAttribute(new MetadataAttr(new Metadata(new TfArchivedate(), new MonoValue($date->format('Y/m/d H:i:s')))));
     $file->addAttribute(new MetadataAttr(new Metadata(new TfRecordid(), new MonoValue($element->get_record_id()))));
     $metadatas = [];
     /**
      * @todo $key is not tagname but fieldname
      */
     $fieldToKeyMap = [];
     if (!$fieldToKeyMap) {
         foreach ($file->getCollection()->get_databox()->get_meta_structure() as $databox_field) {
             $tagname = $databox_field->get_tag()->getTagname();
             if (!isset($fieldToKeyMap[$tagname])) {
                 $fieldToKeyMap[$tagname] = [];
             }
             $fieldToKeyMap[$tagname][] = $databox_field->get_name();
         }
     }
     foreach ($file->getMedia()->getMetadatas() as $metadata) {
         $key = $metadata->getTag()->getTagname();
         if (!isset($fieldToKeyMap[$key])) {
             continue;
         }
         foreach ($fieldToKeyMap[$key] as $k) {
             if (!isset($metadatas[$k])) {
                 $metadatas[$k] = [];
             }
             $metadatas[$k] = array_merge($metadatas[$k], $metadata->getValue()->asArray());
         }
     }
     foreach ($file->getAttributes() as $attribute) {
         switch ($attribute->getName()) {
             /**
              * @todo implement METATAG aka metadata by fieldname (where as
              * current metadata is metadata by source.
              */
             case AttributeInterface::NAME_METAFIELD:
                 $key = $attribute->getField()->get_name();
                 if (!isset($metadatas[$key])) {
                     $metadatas[$key] = [];
                 }
                 $metadatas[$key] = array_merge($metadatas[$key], $attribute->getValue());
                 break;
             case AttributeInterface::NAME_METADATA:
                 $key = $attribute->getValue()->getTag()->getTagname();
                 if (!isset($fieldToKeyMap[$key])) {
                     continue;
                 }
                 foreach ($fieldToKeyMap[$key] as $k) {
                     if (!isset($metadatas[$k])) {
                         $metadatas[$k] = [];
                     }
                     $metadatas[$k] = array_merge($metadatas[$k], $attribute->getValue()->getValue()->asArray());
                 }
                 break;
             case AttributeInterface::NAME_STATUS:
                 $element->set_binary_status(decbin(bindec($element->get_status()) | bindec($attribute->getValue())));
                 break;
             case AttributeInterface::NAME_STORY:
                 $story = $attribute->getValue();
                 if (!$story->hasChild($element)) {
                     $story->appendChild($element);
                 }
                 break;
         }
     }
     $databox = $element->get_databox();
     $metas = [];
     foreach ($metadatas as $fieldname => $values) {
         foreach ($databox->get_meta_structure()->get_elements() as $databox_field) {
             if ($databox_field->get_name() == $fieldname) {
                 if ($databox_field->is_multi()) {
                     $tmpValues = [];
                     foreach ($values as $value) {
                         $tmpValues = array_merge($tmpValues, \caption_field::get_multi_values($value, $databox_field->get_separator()));
                     }
                     $values = array_unique($tmpValues);
                     foreach ($values as $value) {
                         if (!trim($value)) {
                             continue;
                         }
                         $metas[] = ['meta_struct_id' => $databox_field->get_id(), 'meta_id' => null, 'value' => $value];
                     }
                 } else {
                     $value = array_pop($values);
                     if (!trim($value)) {
                         continue;
                     }
                     $metas[] = ['meta_struct_id' => $databox_field->get_id(), 'meta_id' => null, 'value' => $value];
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:101,代码来源:Manager.php

示例13: setUp


//.........这里部分代码省略.........
             return function ($DI) use($fixtureName) {
                 return $DI['app']['repo.users']->find(self::$fixtureIds['user'][$fixtureName]);
             };
         }
         return function ($DI) use($fixtureName) {
             $user = $DI['app']['repo.users']->find(self::$fixtureIds['user'][$fixtureName]);
             self::resetUsersRights($DI['app'], $user);
             return $user;
         };
     };
     foreach ($users as $name => $fixtureName) {
         self::$DI[$name] = self::$DI->share($userFactory($fixtureName));
     }
     self::$DI['registration_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.registrations']->find(self::$fixtureIds['registrations']['registration_1']);
     });
     self::$DI['registration_2'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.registrations']->find(self::$fixtureIds['registrations']['registration_2']);
     });
     self::$DI['registration_3'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.registrations']->find(self::$fixtureIds['registrations']['registration_3']);
     });
     self::$DI['oauth2-app-user'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user']);
     });
     self::$DI['webhook-event'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.webhook-event']->find(self::$fixtureIds['webhook']['event']);
     });
     self::$DI['oauth2-app-user-not-admin'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.api-applications']->find(self::$fixtureIds['oauth']['user-not-admin']);
     });
     self::$DI['oauth2-app-acc-user'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.api-accounts']->find(self::$fixtureIds['oauth']['acc-user']);
     });
     self::$DI['oauth2-app-acc-user-not-admin'] = self::$DI->share(function ($DI) {
         return $DI['app']['repo.api-accounts']->find(self::$fixtureIds['oauth']['acc-user-not-admin']);
     });
     self::$DI['logger'] = self::$DI->share(function () {
         $logger = new Logger('tests');
         $logger->pushHandler(new NullHandler());
         return $logger;
     });
     self::$DI['collection'] = self::$DI->share(function ($DI) {
         return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll']);
     });
     self::$DI['collection_no_access'] = self::$DI->share(function ($DI) {
         return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_access']);
     });
     self::$DI['collection_no_access_by_status'] = self::$DI->share(function ($DI) {
         return collection::get_from_base_id($DI['app'], self::$fixtureIds['collection']['coll_no_status']);
     });
     self::$DI['lazaret_1'] = self::$DI->share(function ($DI) {
         return $DI['app']['orm.em']->find('Phraseanet:LazaretFile', self::$fixtureIds['lazaret']['lazaret_1']);
     });
     foreach (range(1, 7) as $i) {
         self::$DI['record_' . $i] = self::$DI->share(function ($DI) use($i) {
             return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_' . $i]);
         });
     }
     foreach (range(1, 3) as $i) {
         self::$DI['record_story_' . $i] = self::$DI->share(function ($DI) use($i) {
             return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], self::$fixtureIds['record']['record_story_' . $i]);
         });
     }
     self::$DI['record_no_access_resolver'] = self::$DI->protect(function () {
         $id = 'no_access';
         if (isset(self::$fixtureIds['records'][$id])) {
             return self::$fixtureIds['records'][$id];
         }
         self::$recordsInitialized[] = $id;
         $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access']);
         $record = record_adapter::createFromFile($file, self::$DI['app']);
         self::$DI['app']['subdef.generator']->generateSubdefs($record);
         self::$fixtureIds['records'][$id] = $record->get_record_id();
         return self::$fixtureIds['records'][$id];
     });
     self::$DI['record_no_access_by_status_resolver'] = self::$DI->protect(function () {
         $id = 'no_access_by_status';
         if (isset(self::$fixtureIds['records'][$id])) {
             return self::$fixtureIds['records'][$id];
         }
         self::$recordsInitialized[] = $id;
         $file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$DI['collection_no_access_by_status']);
         $record = record_adapter::createFromFile($file, self::$DI['app']);
         self::$DI['app']['subdef.generator']->generateSubdefs($record);
         self::$fixtureIds['records'][$id] = $record->get_record_id();
         return self::$fixtureIds['records'][$id];
     });
     self::$DI['record_no_access'] = self::$DI->share(function ($DI) {
         return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_resolver']());
     });
     self::$DI['record_no_access_by_status'] = self::$DI->share(function ($DI) {
         return new \record_adapter($DI['app'], self::$fixtureIds['databox']['records'], $DI['record_no_access_by_status_resolver']());
     });
     static $decodedFixtureIds;
     if (is_null($decodedFixtureIds)) {
         $decodedFixtureIds = json_decode(file_get_contents(sys_get_temp_dir() . '/fixtures.json'), true);
     }
     self::$fixtureIds = $decodedFixtureIds;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:101,代码来源:PhraseanetTestCase.php


注:本文中的record_adapter::createFromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。