PageRenderTime 47ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/app/bundles/PageBundle/Entity/VideoHit.php

https://gitlab.com/mautic-master/mautic
PHP | 810 lines | 351 code | 122 blank | 337 comment | 0 complexity | dc3fd7e796e9f6838a280fe554c3f856 MD5 | raw file
  1. <?php
  2. /**
  3. * @package Mautic
  4. * @copyright 2014 Mautic Contributors. All rights reserved.
  5. * @author Mautic
  6. * @link http://mautic.org
  7. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
  8. */
  9. namespace Mautic\PageBundle\Entity;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder;
  12. use Mautic\EmailBundle\Entity\Email;
  13. use Mautic\LeadBundle\Entity\Lead;
  14. use Mautic\ApiBundle\Serializer\Driver\ApiMetadataDriver;
  15. /**
  16. * Class VideoHit
  17. *
  18. * @package Mautic\PageBundle\Entity
  19. */
  20. class VideoHit
  21. {
  22. /**
  23. * @var int
  24. */
  25. private $id;
  26. /**
  27. * @var string
  28. */
  29. private $guid;
  30. /**
  31. * @var \DateTime
  32. */
  33. private $dateHit;
  34. /**
  35. * @var \DateTime
  36. */
  37. private $dateLeft;
  38. /**
  39. * @var int
  40. */
  41. private $timeWatched;
  42. /**
  43. * @var int
  44. */
  45. private $duration;
  46. /**
  47. * @var Redirect
  48. */
  49. private $redirect;
  50. /**
  51. * @var \Mautic\LeadBundle\Entity\Lead
  52. */
  53. private $lead;
  54. /**
  55. * @var \Mautic\CoreBundle\Entity\IpAddress
  56. */
  57. private $ipAddress;
  58. /**
  59. * @var string
  60. */
  61. private $country;
  62. /**
  63. * @var string
  64. */
  65. private $region;
  66. /**
  67. * @var string
  68. */
  69. private $city;
  70. /**
  71. * @var string
  72. */
  73. private $isp;
  74. /**
  75. * @var string
  76. */
  77. private $organization;
  78. /**
  79. * @var integer
  80. */
  81. private $code;
  82. /**
  83. * @var
  84. */
  85. private $referer;
  86. /**
  87. * @var
  88. */
  89. private $url;
  90. /**
  91. * @var string
  92. */
  93. private $userAgent;
  94. /**
  95. * @var string
  96. */
  97. private $remoteHost;
  98. /**
  99. * @var string
  100. */
  101. private $pageLanguage;
  102. /**
  103. * @var string
  104. */
  105. private $browserLanguages = array();
  106. /**
  107. * @var string
  108. */
  109. private $channel;
  110. /**
  111. * @var integer
  112. */
  113. private $channelId;
  114. /**
  115. * @var array
  116. */
  117. private $query = array();
  118. /**
  119. * @param ORM\ClassMetadata $metadata
  120. */
  121. public static function loadMetadata (ORM\ClassMetadata $metadata)
  122. {
  123. $builder = new ClassMetadataBuilder($metadata);
  124. $builder->setTable('video_hits')
  125. ->setCustomRepositoryClass('Mautic\PageBundle\Entity\VideoHitRepository')
  126. ->addIndex(['date_hit'], 'video_date_hit')
  127. ->addIndex(['channel', 'channel_id'], 'video_channel_search')
  128. ->addIndex(['guid', 'lead_id'], 'video_guid_lead_search');
  129. $builder->addId();
  130. $builder->createField('dateHit', 'datetime')
  131. ->columnName('date_hit')
  132. ->build();
  133. $builder->createField('dateLeft', 'datetime')
  134. ->columnName('date_left')
  135. ->nullable()
  136. ->build();
  137. $builder->addLead(true, 'SET NULL');
  138. $builder->addIpAddress();
  139. $builder->createField('country', 'string')
  140. ->nullable()
  141. ->build();
  142. $builder->createField('region', 'string')
  143. ->nullable()
  144. ->build();
  145. $builder->createField('city', 'string')
  146. ->nullable()
  147. ->build();
  148. $builder->createField('isp', 'string')
  149. ->nullable()
  150. ->build();
  151. $builder->createField('organization', 'string')
  152. ->nullable()
  153. ->build();
  154. $builder->addField('code', 'integer');
  155. $builder->createField('referer', 'text')
  156. ->nullable()
  157. ->build();
  158. $builder->createField('url', 'text')
  159. ->nullable()
  160. ->build();
  161. $builder->createField('userAgent', 'text')
  162. ->columnName('user_agent')
  163. ->nullable()
  164. ->build();
  165. $builder->createField('remoteHost', 'string')
  166. ->columnName('remote_host')
  167. ->nullable()
  168. ->build();
  169. $builder->createField('guid', 'string')
  170. ->columnName('guid')
  171. ->build();
  172. $builder->createField('pageLanguage', 'string')
  173. ->columnName('page_language')
  174. ->nullable()
  175. ->build();
  176. $builder->createField('browserLanguages', 'array')
  177. ->columnName('browser_languages')
  178. ->nullable()
  179. ->build();
  180. $builder->createField('channel', 'string')
  181. ->nullable()
  182. ->build();
  183. $builder->createField('channelId', 'integer')
  184. ->columnName('channel_id')
  185. ->nullable()
  186. ->build();
  187. $builder->createField('timeWatched', 'integer')
  188. ->columnName('time_watched')
  189. ->nullable()
  190. ->build();
  191. $builder->createField('duration', 'integer')
  192. ->columnName('duration')
  193. ->nullable()
  194. ->build();
  195. $builder->addNullableField('query', 'array');
  196. }
  197. /**
  198. * Prepares the metadata for API usage
  199. *
  200. * @param $metadata
  201. */
  202. public static function loadApiMetadata(ApiMetadataDriver $metadata)
  203. {
  204. $metadata->setGroupPrefix('hit')
  205. ->addProperties(
  206. array(
  207. 'dateHit',
  208. 'dateLeft',
  209. 'lead',
  210. 'ipAddress',
  211. 'country',
  212. 'region',
  213. 'city',
  214. 'isp',
  215. 'code',
  216. 'referer',
  217. 'url',
  218. 'urlTitle',
  219. 'userAgent',
  220. 'remoteHost',
  221. 'pageLanguage',
  222. 'browserLanguages',
  223. 'source',
  224. 'sourceId',
  225. 'query',
  226. 'timeWatched',
  227. 'guid'
  228. )
  229. )
  230. ->build();
  231. }
  232. /**
  233. * Get id
  234. *
  235. * @return integer
  236. */
  237. public function getId()
  238. {
  239. return $this->id;
  240. }
  241. /**
  242. * Set dateHit
  243. *
  244. * @param \DateTime $dateHit
  245. *
  246. * @return VideoHit
  247. */
  248. public function setDateHit($dateHit)
  249. {
  250. $this->dateHit = $dateHit;
  251. return $this;
  252. }
  253. /**
  254. * Get dateHit
  255. *
  256. * @return \DateTime
  257. */
  258. public function getDateHit()
  259. {
  260. return $this->dateHit;
  261. }
  262. /**
  263. * @return \DateTime
  264. */
  265. public function getDateLeft()
  266. {
  267. return $this->dateLeft;
  268. }
  269. /**
  270. * @param \DateTime $dateLeft
  271. *
  272. * @return VideoHit
  273. */
  274. public function setDateLeft($dateLeft)
  275. {
  276. $this->dateLeft = $dateLeft;
  277. return $this;
  278. }
  279. /**
  280. * Set country
  281. *
  282. * @param string $country
  283. *
  284. * @return VideoHit
  285. */
  286. public function setCountry($country)
  287. {
  288. $this->country = $country;
  289. return $this;
  290. }
  291. /**
  292. * Get country
  293. *
  294. * @return string
  295. */
  296. public function getCountry()
  297. {
  298. return $this->country;
  299. }
  300. /**
  301. * Set region
  302. *
  303. * @param string $region
  304. *
  305. * @return VideoHit
  306. */
  307. public function setRegion($region)
  308. {
  309. $this->region = $region;
  310. return $this;
  311. }
  312. /**
  313. * Get region
  314. *
  315. * @return string
  316. */
  317. public function getRegion()
  318. {
  319. return $this->region;
  320. }
  321. /**
  322. * Set city
  323. *
  324. * @param string $city
  325. *
  326. * @return VideoHit
  327. */
  328. public function setCity($city)
  329. {
  330. $this->city = $city;
  331. return $this;
  332. }
  333. /**
  334. * Get city
  335. *
  336. * @return string
  337. */
  338. public function getCity()
  339. {
  340. return $this->city;
  341. }
  342. /**
  343. * Set isp
  344. *
  345. * @param string $isp
  346. *
  347. * @return VideoHit
  348. */
  349. public function setIsp($isp)
  350. {
  351. $this->isp = $isp;
  352. return $this;
  353. }
  354. /**
  355. * Get isp
  356. *
  357. * @return string
  358. */
  359. public function getIsp()
  360. {
  361. return $this->isp;
  362. }
  363. /**
  364. * Set organization
  365. *
  366. * @param string $organization
  367. *
  368. * @return VideoHit
  369. */
  370. public function setOrganization($organization)
  371. {
  372. $this->organization = $organization;
  373. return $this;
  374. }
  375. /**
  376. * Get organization
  377. *
  378. * @return string
  379. */
  380. public function getOrganization()
  381. {
  382. return $this->organization;
  383. }
  384. /**
  385. * Set code
  386. *
  387. * @param integer $code
  388. *
  389. * @return VideoHit
  390. */
  391. public function setCode($code)
  392. {
  393. $this->code = $code;
  394. return $this;
  395. }
  396. /**
  397. * Get code
  398. *
  399. * @return integer
  400. */
  401. public function getCode()
  402. {
  403. return $this->code;
  404. }
  405. /**
  406. * Set referer
  407. *
  408. * @param string $referer
  409. *
  410. * @return VideoHit
  411. */
  412. public function setReferer($referer)
  413. {
  414. $this->referer = $referer;
  415. return $this;
  416. }
  417. /**
  418. * Get referer
  419. *
  420. * @return string
  421. */
  422. public function getReferer()
  423. {
  424. return $this->referer;
  425. }
  426. /**
  427. * Set url
  428. *
  429. * @param string $url
  430. *
  431. * @return VideoHit
  432. */
  433. public function setUrl($url)
  434. {
  435. $this->url = $url;
  436. return $this;
  437. }
  438. /**
  439. * Get url
  440. *
  441. * @return string
  442. */
  443. public function getUrl()
  444. {
  445. return $this->url;
  446. }
  447. /**
  448. * Set userAgent
  449. *
  450. * @param string $userAgent
  451. *
  452. * @return VideoHit
  453. */
  454. public function setUserAgent($userAgent)
  455. {
  456. $this->userAgent = $userAgent;
  457. return $this;
  458. }
  459. /**
  460. * Get userAgent
  461. *
  462. * @return string
  463. */
  464. public function getUserAgent()
  465. {
  466. return $this->userAgent;
  467. }
  468. /**
  469. * Set remoteHost
  470. *
  471. * @param string $remoteHost
  472. *
  473. * @return VideoHit
  474. */
  475. public function setRemoteHost($remoteHost)
  476. {
  477. $this->remoteHost = $remoteHost;
  478. return $this;
  479. }
  480. /**
  481. * Get remoteHost
  482. *
  483. * @return string
  484. */
  485. public function getRemoteHost()
  486. {
  487. return $this->remoteHost;
  488. }
  489. /**
  490. * Set ipAddress
  491. *
  492. * @param \Mautic\CoreBundle\Entity\IpAddress $ipAddress
  493. *
  494. * @return VideoHit
  495. */
  496. public function setIpAddress(\Mautic\CoreBundle\Entity\IpAddress $ipAddress)
  497. {
  498. $this->ipAddress = $ipAddress;
  499. return $this;
  500. }
  501. /**
  502. * Get ipAddress
  503. *
  504. * @return \Mautic\CoreBundle\Entity\IpAddress
  505. */
  506. public function getIpAddress()
  507. {
  508. return $this->ipAddress;
  509. }
  510. /**
  511. * Set pageLanguage
  512. *
  513. * @param string $pageLanguage
  514. *
  515. * @return VideoHit
  516. */
  517. public function setPageLanguage($pageLanguage)
  518. {
  519. $this->pageLanguage = $pageLanguage;
  520. return $this;
  521. }
  522. /**
  523. * Get pageLanguage
  524. *
  525. * @return string
  526. */
  527. public function getPageLanguage()
  528. {
  529. return $this->pageLanguage;
  530. }
  531. /**
  532. * Set browserLanguages
  533. *
  534. * @param string $browserLanguages
  535. *
  536. * @return VideoHit
  537. */
  538. public function setBrowserLanguages($browserLanguages)
  539. {
  540. $this->browserLanguages = $browserLanguages;
  541. return $this;
  542. }
  543. /**
  544. * Get browserLanguages
  545. *
  546. * @return string
  547. */
  548. public function getBrowserLanguages()
  549. {
  550. return $this->browserLanguages;
  551. }
  552. /**
  553. * @return Lead
  554. */
  555. public function getLead()
  556. {
  557. return $this->lead;
  558. }
  559. /**
  560. * @param Lead $lead
  561. *
  562. * @return VideoHit
  563. */
  564. public function setLead(Lead $lead)
  565. {
  566. $this->lead = $lead;
  567. return $this;
  568. }
  569. /**
  570. * @return string
  571. */
  572. public function getChannel()
  573. {
  574. return $this->channel;
  575. }
  576. /**
  577. * @param string $channel
  578. *
  579. * @return VideoHit
  580. */
  581. public function setChannel($channel)
  582. {
  583. $this->channel = $channel;
  584. return $this;
  585. }
  586. /**
  587. * @return integer
  588. */
  589. public function getChannelId()
  590. {
  591. return $this->channelId;
  592. }
  593. /**
  594. * @param integer $channelId
  595. *
  596. * @return VideoHit
  597. */
  598. public function setChannelId($channelId)
  599. {
  600. $this->channelId = (int) $channelId;
  601. return $this;
  602. }
  603. /**
  604. * @return Redirect
  605. */
  606. public function getRedirect()
  607. {
  608. return $this->redirect;
  609. }
  610. /**
  611. * @param Redirect $redirect
  612. *
  613. * @return VideoHit
  614. */
  615. public function setRedirect(Redirect $redirect)
  616. {
  617. $this->redirect = $redirect;
  618. return $this;
  619. }
  620. /**
  621. * @return array
  622. */
  623. public function getQuery()
  624. {
  625. return $this->query;
  626. }
  627. /**
  628. * @param array $query
  629. *
  630. * @return VideoHit
  631. */
  632. public function setQuery($query)
  633. {
  634. $this->query = $query;
  635. return $this;
  636. }
  637. /**
  638. * @return int
  639. */
  640. public function getTimeWatched()
  641. {
  642. return $this->timeWatched;
  643. }
  644. /**
  645. * @param $timeWatched
  646. *
  647. * @return VideoHit
  648. */
  649. public function setTimeWatched($timeWatched)
  650. {
  651. $this->timeWatched = $timeWatched;
  652. return $this;
  653. }
  654. /**
  655. * @return string
  656. */
  657. public function getGuid()
  658. {
  659. return $this->guid;
  660. }
  661. /**
  662. * @param string $guid
  663. *
  664. * @return VideoHit
  665. */
  666. public function setGuid($guid)
  667. {
  668. $this->guid = $guid;
  669. return $this;
  670. }
  671. /**
  672. * @return int
  673. */
  674. public function getDuration()
  675. {
  676. return $this->duration;
  677. }
  678. /**
  679. * @param int $duration
  680. *
  681. * @return VideoHit
  682. */
  683. public function setDuration($duration)
  684. {
  685. $this->duration = $duration;
  686. return $this;
  687. }
  688. }