This repository was archived by the owner on Oct 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 18 files changed +40
-0
lines changed Expand file tree Collapse file tree 18 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,28 @@ protected function reflectFields()
7272 }
7373 }
7474
75+ protected function reflectReference ()
76+ {
77+ $ reflectionClass = new \ReflectionClass ($ this ->class ->getClassName ());
78+ if (!$ reflectionClass ->isSubclassOf ('Commercetools\Core\Model\Common\Resource ' )) {
79+ return ;
80+ }
81+
82+ $ referenceClass = $ this ->class ->getClassName () . 'Reference ' ;
83+ $ referenceShortName = $ this ->class ->getShortClassName () . 'Reference ' ;
84+ if (class_exists ($ referenceClass )) {
85+ $ this ->class ->addMagicMethod (
86+ 'getReference ' ,
87+ [],
88+ $ referenceShortName ,
89+ null ,
90+ null ,
91+ false ,
92+ true
93+ );
94+ }
95+ }
96+
7597 protected function reflectElementType ()
7698 {
7799 $ reflectionClass = new \ReflectionClass ($ this ->class ->getClassName ());
@@ -163,6 +185,7 @@ public function generate()
163185 }
164186
165187 $ this ->reflectFields ();
188+ $ this ->reflectReference ();
166189 $ this ->annotate ();
167190 }
168191
Original file line number Diff line number Diff line change 5757 * @method Cart setCustom(CustomFieldObject $custom = null)
5858 * @method PaymentInfo getPaymentInfo()
5959 * @method Cart setPaymentInfo(PaymentInfo $paymentInfo = null)
60+ * @method CartReference getReference()
6061 */
6162class Cart extends Resource
6263{
Original file line number Diff line number Diff line change 4343 * @method CartDiscount setRequiresDiscountCode(bool $requiresDiscountCode = null)
4444 * @method ReferenceCollection getReferences()
4545 * @method CartDiscount setReferences(ReferenceCollection $references = null)
46+ * @method CartDiscountReference getReference()
4647 */
4748class CartDiscount extends Resource
4849{
Original file line number Diff line number Diff line change 4343 * @method Category setMetaTitle(LocalizedString $metaTitle = null)
4444 * @method LocalizedString getMetaKeywords()
4545 * @method Category setMetaKeywords(LocalizedString $metaKeywords = null)
46+ * @method CategoryReference getReference()
4647 */
4748class Category extends Resource
4849{
Original file line number Diff line number Diff line change 3434 * @method Channel setCustom(CustomFieldObject $custom = null)
3535 * @method ReviewRatingStatistics getReviewRatingStatistics()
3636 * @method Channel setReviewRatingStatistics(ReviewRatingStatistics $reviewRatingStatistics = null)
37+ * @method ChannelReference getReference()
3738 */
3839class Channel extends Resource
3940{
Original file line number Diff line number Diff line change 5757 * @method Customer setCustomerGroup(CustomerGroupReference $customerGroup = null)
5858 * @method CustomFieldObject getCustom()
5959 * @method Customer setCustom(CustomFieldObject $custom = null)
60+ * @method CustomerReference getReference()
6061 */
6162class Customer extends Resource
6263{
Original file line number Diff line number Diff line change 2121 * @method CustomerGroup setLastModifiedAt(\DateTime $lastModifiedAt = null)
2222 * @method string getName()
2323 * @method CustomerGroup setName(string $name = null)
24+ * @method CustomerGroupReference getReference()
2425 */
2526class CustomerGroup extends Resource
2627{
Original file line number Diff line number Diff line change 4040 * @method DiscountCode setMaxApplications(int $maxApplications = null)
4141 * @method int getMaxApplicationsPerCustomer()
4242 * @method DiscountCode setMaxApplicationsPerCustomer(int $maxApplicationsPerCustomer = null)
43+ * @method DiscountCodeReference getReference()
4344 */
4445class DiscountCode extends Resource
4546{
Original file line number Diff line number Diff line change 7979 * @method Order setState(StateReference $state = null)
8080 * @method PaymentInfo getPaymentInfo()
8181 * @method Order setPaymentInfo(PaymentInfo $paymentInfo = null)
82+ * @method OrderReference getReference()
8283 */
8384class Order extends Resource
8485{
Original file line number Diff line number Diff line change 4949 * @method Payment setTransactions(TransactionCollection $transactions = null)
5050 * @method CustomFieldObjectCollection getInterfaceInteractions()
5151 * @method Payment setInterfaceInteractions(CustomFieldObjectCollection $interfaceInteractions = null)
52+ * @method PaymentReference getReference()
5253 */
5354class Payment extends Resource
5455{
You can’t perform that action at this time.
0 commit comments