setAuthor() public method

public setAuthor ( string $author )
$author string
コード例 #1
0
ファイル: Repo.php プロジェクト: KnpLabs/KnpBundles
 public function updateCommits(Bundle $bundle)
 {
     $this->output->write(' commits');
     try {
         $commits = $this->github->api('repo')->commits()->all($bundle->getOwnerName(), $bundle->getName(), array('sha' => 'HEAD', 'per_page' => 30));
     } catch (RuntimeException $e) {
         return false;
     }
     $activities = $bundle->getLatestActivities();
     $lastEverCommitAt = $bundle->getLastCommitAt();
     /* @var $developer EntityDeveloper */
     foreach ($commits as $commit) {
         if (!isset($commit['commit']['committer'])) {
             continue;
         }
         $lastCommitAt = new \DateTime($commit['commit']['committer']['date']);
         $lastCommitAt->setTimezone(new \DateTimeZone(date_default_timezone_get()));
         $activityData = array('type' => Activity::ACTIVITY_TYPE_COMMIT, 'message' => strtok($commit['commit']['message'], "\n\r"), 'createdAt' => $lastCommitAt);
         if (!empty($activities)) {
             foreach ($activities as $registeredActivity) {
                 if ($registeredActivity->getMessage() === $activityData['message'] && $registeredActivity->getCreatedAt() == $activityData['createdAt']) {
                     continue 2;
                 }
             }
         }
         // be sure that bundle have a latest date following to latest commit
         if ($lastCommitAt > $lastEverCommitAt) {
             $lastEverCommitAt = $lastCommitAt;
         }
         $activity = new Activity();
         $activity->setType($activityData['type']);
         $activity->setMessage($activityData['message']);
         $activity->setCreatedAt($activityData['createdAt']);
         $activity->setBundle($bundle);
         if (isset($commit['committer']) && isset($commit['committer']['login'])) {
             $developer = $this->ownerManager->createOwner($commit['committer']['login'], 'developer', true);
             $developer->setLastCommitAt($lastCommitAt);
             $activity->setDeveloper($developer);
         } else {
             $activity->setAuthor($commit['commit']['committer']['name']);
         }
     }
     // update last pushed commit date
     $bundle->setLastCommitAt(clone $lastEverCommitAt);
     if ('developer' === $bundle->getOwnerType()) {
         $bundle->getOwner()->setLastCommitAt(clone $lastEverCommitAt);
     }
     unset($activities);
     return true;
 }
コード例 #2
0
ファイル: Data.php プロジェクト: KnpLabs/KnpBundles
 protected function makeBundle($manager, Entity\Owner $owner, $i, $contributor = null)
 {
     $trilean = array(true, false, null);
     $bundle = new Entity\Bundle();
     $bundle->fromArray(array('name' => ucfirst($owner->getName()) . $i . 'FooBundle', 'description' => $this->descriptions[mt_rand(0, 4)], 'homepage' => $i % 2 ? 'Bundle' . $i . '.com' : null, 'readme' => str_replace('__BUNDLE__', "the bundle number: {$i}", $this->readme), 'usesTravisCi' => $i % 2 ? false : true, 'composerName' => $i % 2 ? null : 'knplabs/knp-menu-bundle', 'versionsHistory' => array('symfony' => array('dev-master' => '2.1.*', '1.2.0' => '2.0.*', '1.1.0' => '2.*'), 'dependencies' => array('dev-master' => array('name' => 'friendsofsymfony/user-bundle', 'extra' => array('branch-alias' => array('dev-master' => '2.0.x-dev')), 'require' => array('php' => '>=5.3.2', 'symfony/framework-bundle' => '>=2.1,<2.3-dev', 'symfony/security-bundle' => '>=2.1,<2.3-dev'), 'require-dev' => array('twig/twig' => '*', 'doctrine/doctrine-bundle' => '*', 'swiftmailer/swiftmailer' => '*', 'willdurand/propel-typehintable-behavior' => 'dev-master', 'symfony/validator' => '2.1.*', 'symfony/yaml' => '2.1.*'), 'suggest' => array('doctrine/couchdb-odm-bundle' => '*', 'doctrine/doctrine-bundle' => '*', 'doctrine/mongodb-odm-bundle' => '*')), '1.2.x-dev' => array('name' => 'friendsofsymfony/user-bundle', 'require' => array('php' => '>=5.3.2', 'symfony/framework-bundle' => '>=2.1,<2.3-dev', 'symfony/security-bundle' => '>=2.1,<2.3-dev'), 'require-dev' => '', 'suggest' => ''))), 'state' => $this->states[mt_rand(0, 3)], 'license' => $i % 4 == 0 ? 'Some pseudo license data' : null, 'licenseType' => $i % 3 == 0 ? $this->licenses[mt_rand(0, 2)] : null, 'travisCiBuildStatus' => $i % 2 == 0 ? $trilean[$i % 3] : null, 'nbFollowers' => $i * 10, 'nbForks' => $i, 'isFork' => false, 'contributors' => $contributor ? array($contributor) : array(), 'canonicalConfig' => $i % 2 == 0 ? $this->canonicalConfigDump : null, 'nbRecommenders' => rand(0, 90)));
     $commits = array(array('date' => '2010-05-16T09:58:32-09:00', 'author' => $owner instanceof Entity\Developer ? $owner->getName() : 'Random Person', 'message' => 'Fix something on this Bundle'), array('date' => '2010-05-16T09:58:32-07:00', 'author' => 'Fake Name', 'message' => 'Commit something on this bundle'));
     foreach ($commits as $commit) {
         $lastCommitAt = new \DateTime();
         $lastCommitAt->setTimestamp(strtotime($commit['date']));
         $bundle->setLastCommitAt($lastCommitAt);
         $activity = new Entity\Activity();
         $activity->setType(Entity\Activity::ACTIVITY_TYPE_COMMIT);
         $activity->setMessage(strtok($commit['message'], "\n\r"));
         $activity->setCreatedAt($lastCommitAt);
         $activity->setBundle($bundle);
         if ($owner->getName() == $commit['author']) {
             $owner->setLastCommitAt($lastCommitAt);
             $activity->setDeveloper($owner);
             $activity->setBundleOwnerName(strtolower($owner->getName()));
         } else {
             $activity->setAuthor($commit['author']);
             $activity->setBundleOwnerName(strtolower($commit['author']));
         }
         $manager->persist($activity);
     }
     $owner->addBundle($bundle);
     return $bundle;
 }