Skip to content

Commit 7534497

Browse files
committed
updated
0 parents  commit 7534497

20 files changed

+1061
-0
lines changed

Helper/Data.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2019 Landofcoder
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
24+
namespace Lof\CustomCustomerInfo\Helper;
25+
26+
use Magento\Framework\App\Helper\AbstractHelper;
27+
28+
class Data extends AbstractHelper
29+
{
30+
31+
/**
32+
* @param \Magento\Framework\App\Helper\Context $context
33+
*/
34+
public function __construct(
35+
\Magento\Framework\App\Helper\Context $context
36+
) {
37+
parent::__construct($context);
38+
}
39+
40+
/**
41+
* @return bool
42+
*/
43+
public function isEnabled()
44+
{
45+
return true;
46+
}
47+
}

LICENSE.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2019 Landofcoder
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

Setup/InstallData.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2019 Landofcoder
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
24+
namespace Lof\CustomCustomerInfo\Setup;
25+
26+
use Magento\Framework\Setup\InstallDataInterface;
27+
use Magento\Framework\Setup\ModuleContextInterface;
28+
use Magento\Framework\Setup\ModuleDataSetupInterface;
29+
30+
class InstallData implements InstallDataInterface
31+
{
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
public function install(
37+
ModuleDataSetupInterface $setup,
38+
ModuleContextInterface $context
39+
) {
40+
//Your install script
41+
}
42+
}

Setup/InstallSchema.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2019 Landofcoder
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
24+
namespace Lof\CustomCustomerInfo\Setup;
25+
26+
use Magento\Framework\Setup\InstallSchemaInterface;
27+
use Magento\Framework\Setup\ModuleContextInterface;
28+
use Magento\Framework\Setup\SchemaSetupInterface;
29+
30+
class InstallSchema implements InstallSchemaInterface
31+
{
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
public function install(
37+
SchemaSetupInterface $setup,
38+
ModuleContextInterface $context
39+
) {
40+
//Your install script
41+
}
42+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2019 Landofcoder
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
24+
namespace Lof\CustomCustomerInfo\Setup\Patch\Data;
25+
26+
use Magento\Framework\Setup\Patch\DataPatchInterface;
27+
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
28+
use Magento\Framework\Setup\ModuleDataSetupInterface;
29+
use Magento\Customer\Setup\CustomerSetupFactory;
30+
use Magento\Customer\Setup\CustomerSetup;
31+
32+
class AddAvatarCustomerAttribute implements DataPatchInterface, PatchRevertableInterface
33+
{
34+
35+
/**
36+
* @var ModuleDataSetupInterface
37+
*/
38+
private $moduleDataSetup;
39+
/**
40+
* @var CustomerSetup
41+
*/
42+
private $customerSetupFactory;
43+
44+
/**
45+
* Constructor
46+
*
47+
* @param ModuleDataSetupInterface $moduleDataSetup
48+
* @param CustomerSetupFactory $customerSetupFactory
49+
*/
50+
public function __construct(
51+
ModuleDataSetupInterface $moduleDataSetup,
52+
CustomerSetupFactory $customerSetupFactory
53+
) {
54+
$this->moduleDataSetup = $moduleDataSetup;
55+
$this->customerSetupFactory = $customerSetupFactory;
56+
}
57+
58+
/**
59+
* {@inheritdoc}
60+
*/
61+
public function apply()
62+
{
63+
$this->moduleDataSetup->getConnection()->startSetup();
64+
/** @var CustomerSetup $customerSetup */
65+
$customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
66+
$customerSetup->addAttribute(
67+
\Magento\Customer\Model\Customer::ENTITY,
68+
'avatar',
69+
[
70+
'type' => 'varchar',
71+
'label' => 'avatar',
72+
'input' => 'text',
73+
'source' => '',
74+
'required' => true,
75+
'visible' => true,
76+
'position' => 333,
77+
'system' => false,
78+
'backend' => ''
79+
]
80+
);
81+
82+
$attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'avatar')->addData([
83+
'used_in_forms' => [
84+
'adminhtml_customer',
85+
'adminhtml_checkout',
86+
'customer_account_create',
87+
'customer_account_edit'
88+
]
89+
]);
90+
$attribute->save();
91+
92+
$this->moduleDataSetup->getConnection()->endSetup();
93+
}
94+
95+
public function revert()
96+
{
97+
$this->moduleDataSetup->getConnection()->startSetup();
98+
/** @var CustomerSetup $customerSetup */
99+
$customerSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
100+
$customerSetup->removeAttribute(\Magento\Customer\Model\Customer::ENTITY, 'avatar');
101+
102+
$this->moduleDataSetup->getConnection()->endSetup();
103+
}
104+
105+
/**
106+
* {@inheritdoc}
107+
*/
108+
public function getAliases()
109+
{
110+
return [];
111+
}
112+
113+
/**
114+
* {@inheritdoc}
115+
*/
116+
public static function getDependencies()
117+
{
118+
return [
119+
120+
];
121+
}
122+
}

0 commit comments

Comments
 (0)